From dbb088b034e19e99ec209cbbc4eed3bff64172da Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 1 Jul 2003 23:40:59 +0400 Subject: [PATCH 001/282] First version of new authentification procedure: now authentification is one-stage (instead of two-stage in 4.1) For now following tasks have been done: - PASSWORD() function was rewritten. PASSWORD() now returns SHA1 hash_stage2; for new passwords user.password contains '*'hash_stage2; sql_yacc.yy also fixed; - password.c: new functions were implemented, old rolled back to 4.0 state - server code was rewritten to use new authorization algorithm (check_user(), change user, and other stuff in sql/sql_parse.cc) - client code was rewritten to use new authorization algorithm (mysql_real_connect, myslq_authenticate in sql-common/client.c) - now server barks on 45-byte-length 4.1.0 passwords and refuses 4.1.0-style authentification. Users with 4.1.0 passwords are blocked (sql/sql_acl.cc) - mysqladmin.c was fixed to work correctly with new passwords Tests for 4.0-4.1.1, 4.1.1-4.1.1 (with or without db/password) logons was performed; mysqladmin also was tested. Additional check are nevertheless necessary. BitKeeper/etc/ignore: Added start_mysqld.sh mysys/main.cc to the ignore list client/mysqladmin.c: fixed with new password api include/mysql.h: So as scramble_323 accepts only null-terminated message, two scramble buffs are necessary. gotta be fixed include/mysql_com.h: new constants and password.c api changes libmysql/libmysql.c: mysql_change_user rewritten to work with new password api scripts/mysql_create_system_tables.sh: fixed 'Password' column length to 41 scripts/mysql_fix_privilege_tables.sql: fixed 'Password' column length to 41 sql-common/client.c: mysql_real_connect rewritten to support new handshake procedure sql/item_strfunc.cc: Item_func_password and Item_func_old_password rewritten with new password api sql/item_strfunc.h: bit commented, numbers replaced with #defined constants sql/mysql_priv.h: removed unnecessary declaration as now all constants defined is in mysql_com.h sql/mysqld.cc: scramble initialization moved to sql_parce.cc:check_connection sql/password.c: All 4.1 functions were rolled back to 4.0 with attempt to save all possible 4.0-4.1 changes. Names for 4.0 functions were suffixed with '_323' Functions for new handshake were added. sql/slave.cc: Fixed to new constant; Bug #766 remains to be fixed sql/slave.h: fixed to new constant; Buf #766 remains to be fixed sql/sql_acl.cc: rewritten to support new passwords (41 byte-long) and password api sql/sql_acl.h: ditto sql/sql_class.cc: initialization for new members added sql/sql_class.h: same thing as in struct mysql - scramble is used for new family of functions, scramble_323 - for old sql/sql_parse.cc: check_connections was renamed to check_connection as this name reflects better what this function does authorization part of check_connection was rewritten check_user was rewritten with new password and acl api new function 'authenticate', which optionally re-request scramble from client was added fixed some typos COM_CHANGE_USER piece of dipsatch_command() was rewritten sql/sql_repl.h: HASH_PASSWORD_LENGTH replaced with SCRAMBLED_PASSWORD_CHAR_LENGTH bug #766 remains sql/sql_yacc.yy: Two-argument form of PASSWORD() was removed PASSWORD() function was fixed with new password api. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- .bzrignore | 2 + BitKeeper/etc/logging_ok | 1 + client/mysqladmin.c | 9 +- include/mysql.h | 4 +- include/mysql_com.h | 61 +- libmysql/libmysql.c | 58 +- scripts/mysql_create_system_tables.sh | 2 +- scripts/mysql_fix_privilege_tables.sql | 2 +- sql-common/client.c | 166 ++--- sql/item_strfunc.cc | 96 +-- sql/item_strfunc.h | 30 +- sql/mysql_priv.h | 3 - sql/mysqld.cc | 6 - sql/password.c | 918 ++++++++++--------------- sql/slave.cc | 6 +- sql/slave.h | 2 +- sql/sql_acl.cc | 663 +++++++++--------- sql/sql_acl.h | 13 +- sql/sql_class.cc | 1 + sql/sql_class.h | 14 +- sql/sql_parse.cc | 582 +++++++--------- sql/sql_repl.h | 2 +- sql/sql_yacc.yy | 50 +- 23 files changed, 1186 insertions(+), 1505 deletions(-) diff --git a/.bzrignore b/.bzrignore index 4e9ce4e41ab..a23384d4170 100644 --- a/.bzrignore +++ b/.bzrignore @@ -622,3 +622,5 @@ vio/test-ssl vio/test-sslclient vio/test-sslserver vio/viotest-ssl +start_mysqld.sh +mysys/main.cc diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 794edcdd968..ac862cc9770 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -51,6 +51,7 @@ jcole@sarvik.tfr.cafe.ee jcole@tetra.spaceapes.com jorge@linux.jorge.mysql.com kaj@work.mysql.com +kostja@oak.local lenz@kallisto.mysql.com lenz@mysql.com miguel@hegel.(none) diff --git a/client/mysqladmin.c b/client/mysqladmin.c index 018bcbc1963..f263d321a7b 100644 --- a/client/mysqladmin.c +++ b/client/mysqladmin.c @@ -769,9 +769,12 @@ static int execute_commands(MYSQL *mysql,int argc, char **argv) return 1; } if (argv[1][0]) - make_scrambled_password(crypted_pw,argv[1], - (find_type(argv[0], &command_typelib, 2) == - ADMIN_OLD_PASSWORD), &rand_st); + { + if (find_type(argv[0], &command_typelib, 2) == ADMIN_OLD_PASSWORD) + make_scrambled_password_323(crypted_pw, argv[1]); + else + make_scrambled_password(crypted_pw, argv[1]); + } else crypted_pw[0]=0; /* No password */ sprintf(buff,"set password='%s',sql_log_off=0",crypted_pw); diff --git a/include/mysql.h b/include/mysql.h index bd63a10ba45..91ef481e7f7 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -227,7 +227,9 @@ typedef struct st_mysql enum mysql_status status; my_bool free_me; /* If free in mysql_close */ my_bool reconnect; /* set to 1 if automatic reconnect */ - char scramble_buff[21]; /* New protocol requires longer scramble*/ + + char scramble[SCRAMBLE_LENGTH+1]; /* for new servers */ + char scramble_323[SCRAMBLE_LENGTH_323+1]; /* for old servers */ /* Set if this is the original connection, not a master or a slave we have diff --git a/include/mysql_com.h b/include/mysql_com.h index e87001ff27d..c1f18160667 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -48,8 +48,15 @@ enum enum_server_command }; -#define SCRAMBLE_LENGTH 8 -#define SCRAMBLE41_LENGTH 20 +/* + Length of random string sent by server on handshake; this is also length of + obfuscated password, recieved from client +*/ +#define SCRAMBLE_LENGTH 20 +#define SCRAMBLE_LENGTH_323 8 +/* length of password stored in the db: new passwords are preceeded with '*' */ +#define SCRAMBLED_PASSWORD_CHAR_LENGTH (SCRAMBLE_LENGTH*2+1) +#define SCRAMBLED_PASSWORD_CHAR_LENGTH_323 (SCRAMBLE_LENGTH_323*2) #define NOT_NULL_FLAG 1 /* Field can't be NULL */ @@ -300,31 +307,35 @@ extern "C" { extern unsigned long max_allowed_packet; extern unsigned long net_buffer_length; -void randominit(struct rand_struct *,unsigned long seed1, - unsigned long seed2); +/* + These functions are used for authentication by client and server and + implemented in sql/password.c +*/ + +void randominit(struct rand_struct *, unsigned long seed1, + unsigned long seed2); double my_rnd(struct rand_struct *); -void make_scrambled_password(char *to,const char *password, - my_bool force_old_scramble,struct rand_struct *rand_st); -int get_password_length(my_bool force_old_scramble); -char get_password_version(const char* password); -void create_random_string(int length,struct rand_struct *rand_st,char* target); -my_bool validate_password(const char* password, const char* message, - unsigned long* salt); -void password_hash_stage1(char *to, const char *password); -void password_hash_stage2(char *to,const char *salt); -void password_crypt(const char* from,char* to, const char* password,int length); -void get_hash_and_password(unsigned long* salt, unsigned char pversion,char* hash, - unsigned char* bin_password); -void get_salt_from_password(unsigned long *res,const char *password); -void create_key_from_old_password(const char* password,char* key); -void make_password_from_salt(char *to, unsigned long *hash_res, - unsigned char password_version); -char *scramble(char *to,const char *message,const char *password, - my_bool old_ver); -my_bool check_scramble(const char *, const char *message, - unsigned long *salt,my_bool old_ver); +void create_random_string(char *to, uint length, struct rand_struct *rand_st); + +void hash_password(ulong *to, const char *password); +void make_scrambled_password_323(char *to, const char *password); +char *scramble_323(char *to, const char *message, const char *password, + my_bool old_ver); +my_bool check_scramble_323(const char *, const char *message, + unsigned long *salt, my_bool old_ver); +void get_salt_from_password_323(unsigned long *res, const char *password); +void make_password_from_salt_323(char *to, const unsigned long *salt); + +void make_scrambled_password(char *to, const char *password); +char *scramble(char *to, const char *message, const char *password); +my_bool check_scramble(const char *reply, const char *message, + const unsigned char *hash_stage2); +void get_salt_from_password(unsigned char *res, const char *password); +void make_password_from_salt(char *to, const unsigned char *hash_stage2); + +/* end of password.c */ + char *get_tty_password(char *opt_message); -void hash_password(unsigned long *result, const char *password); const char *mysql_errno_to_sqlstate(unsigned int mysql_errno); /* Some other useful functions */ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 771278c1dbb..6bc38abb060 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -616,41 +616,51 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, /* Store user into the buffer */ end=strmov(end,user)+1; - /* - We always start with old type handshake the only difference is message sent - If server handles secure connection type we'll not send the real scramble - */ - if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + /* write scrambled password according to server capabilities */ + if (passwd[0]) { - if (passwd[0]) - { - /* Prepare false scramble */ - bfill(end, SCRAMBLE_LENGTH, 'x'); - end+=SCRAMBLE_LENGTH; - *end=0; - - } - else /* For empty password */ - *end=0; /* zero length scramble */ + /* Write NULL-terminated scrambled password: */ + end= mysql->server_capabilities & CLIENT_SECURE_CONNECTION ? + scramble(end, mysql->scramble, passwd) : + scramble_323(end, mysql->scramble_323, passwd, + (my_bool) (mysql->protocol_version == 9)); } else - { - /* - Real scramble is only sent to old servers. This can be blocked - by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1); - */ - end=scramble(end, mysql->scramble_buff, passwd, - (my_bool) (mysql->protocol_version == 9)); - } + *end= '\0'; // empty password /* Add database if needed */ end=strmov(end+1,db ? db : ""); /* Write authentication package */ simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (end-buff),1); - if (mysql_autenticate(mysql, passwd)) + NET *net= &mysql->net; + ulong pkt_length= net_safe_read(mysql); + + if (pkt_length == packet_error) goto error; + if (net->read_pos[0] == mysql->scramble_323[0] && + pkt_length == SCRAMBLE_LENGTH_323 + 1 && + mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + { + /* + By sending this very specific reply server asks us to send scrambled + password in old format. The reply contains scramble_323. + */ + scramble_323(buff, mysql->scramble_323, passwd, + (my_bool) (mysql->protocol_version == 9)); + if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) + { + net->last_errno= CR_SERVER_LOST; + strmov(net->sqlstate, unknown_sqlstate); + strmov(net->last_error,ER(net->last_errno)); + goto error; + } + /* Read what server thinks about out new auth message report */ + if (net_safe_read(mysql) == packet_error) + goto error; + } + /* Free old connect information */ my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR)); diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index 2739c45e750..c4cdc7b52d7 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -108,7 +108,7 @@ then c_u="$c_u CREATE TABLE user (" c_u="$c_u Host char(60) binary DEFAULT '' NOT NULL," c_u="$c_u User char(16) binary DEFAULT '' NOT NULL," - c_u="$c_u Password char(45) binary DEFAULT '' NOT NULL," + c_u="$c_u Password char(41) binary DEFAULT '' NOT NULL," c_u="$c_u Select_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Insert_priv enum('N','Y') DEFAULT 'N' NOT NULL," c_u="$c_u Update_priv enum('N','Y') DEFAULT 'N' NOT NULL," diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 43dc6d89481..8c5b29a49ff 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -4,7 +4,7 @@ ALTER TABLE host type=MyISAM; ALTER TABLE func type=MyISAM; ALTER TABLE columns_priv type=MyISAM; ALTER TABLE tables_priv type=MyISAM; -ALTER TABLE user change Password Password char(45) not null; +ALTER TABLE user change Password Password char(41) not null; ALTER TABLE user add File_priv enum('N','Y') NOT NULL; CREATE TABLE IF NOT EXISTS func ( name char(64) DEFAULT '' NOT NULL, diff --git a/sql-common/client.c b/sql-common/client.c index 721164c8301..35dea62edc3 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1334,76 +1334,6 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused))) #endif /* HAVE_OPENSSL */ -/* - Handle password authentication -*/ - -my_bool mysql_autenticate(MYSQL *mysql, const char *passwd) -{ - ulong pkt_length; - NET *net= &mysql->net; - char buff[SCRAMBLE41_LENGTH]; - char password_hash[SCRAMBLE41_LENGTH]; /* Used for storage of stage1 hash */ - - /* We shall only query server if it expect us to do so */ - if ((pkt_length=net_safe_read(mysql)) == packet_error) - goto error; - - if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) - { - /* - This should always happen with new server unless empty password - OK/Error packets have zero as the first char - */ - if (pkt_length == 24 && net->read_pos[0]) - { - /* Old passwords will have '*' at the first byte of hash */ - if (net->read_pos[0] != '*') - { - /* Build full password hash as it is required to decode scramble */ - password_hash_stage1(buff, passwd); - /* Store copy as we'll need it later */ - memcpy(password_hash,buff,SCRAMBLE41_LENGTH); - /* Finally hash complete password using hash we got from server */ - password_hash_stage2(password_hash,(const char*) net->read_pos); - /* Decypt and store scramble 4 = hash for stage2 */ - password_crypt((const char*) net->read_pos+4,mysql->scramble_buff, - password_hash, SCRAMBLE41_LENGTH); - mysql->scramble_buff[SCRAMBLE41_LENGTH]=0; - /* Encode scramble with password. Recycle buffer */ - password_crypt(mysql->scramble_buff,buff,buff,SCRAMBLE41_LENGTH); - } - else - { - /* Create password to decode scramble */ - create_key_from_old_password(passwd,password_hash); - /* Decypt and store scramble 4 = hash for stage2 */ - password_crypt((const char*) net->read_pos+4,mysql->scramble_buff, - password_hash, SCRAMBLE41_LENGTH); - mysql->scramble_buff[SCRAMBLE41_LENGTH]=0; - /* Finally scramble decoded scramble with password */ - scramble(buff, mysql->scramble_buff, passwd,0); - } - /* Write second package of authentication */ - if (my_net_write(net,buff,SCRAMBLE41_LENGTH) || net_flush(net)) - { - net->last_errno= CR_SERVER_LOST; - strmov(net->sqlstate, unknown_sqlstate); - strmov(net->last_error,ER(net->last_errno)); - goto error; - } - /* Read what server thinks about out new auth message report */ - if (net_safe_read(mysql) == packet_error) - goto error; - } - } - return 0; - -error: - return 1; -} - - /* Note that the mysql argument must be initialized with mysql_init() before calling mysql_real_connect ! @@ -1481,7 +1411,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, mysql->server_status=SERVER_STATUS_AUTOCOMMIT; /* - Grab a socket and connect it to the server + Part 0: Grab a socket and connect it to the server */ #if defined(HAVE_SMEM) if ((!mysql->options.protocol || @@ -1682,6 +1612,11 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, strmov(net->last_error,ER(net->last_errno)); goto error; } + + /* + Part 1: Connection established, read and parse first packet + */ + if ((pkt_length=net_safe_read(mysql)) == packet_error) goto error; @@ -1702,8 +1637,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, end=strend((char*) net->read_pos+1); mysql->thread_id=uint4korr(end+1); end+=5; - strmake(mysql->scramble_buff,end,8); - end+=9; + /* + Scramble is split into two parts because old clients does not understand + long scrambles; here goes the first part. + */ + strmake(mysql->scramble_323, end, SCRAMBLE_LENGTH_323); + end+= SCRAMBLE_LENGTH_323+1; + memcpy(mysql->scramble, mysql->scramble_323, SCRAMBLE_LENGTH_323); + if (pkt_length >= (uint) (end+1 - (char*) net->read_pos)) mysql->server_capabilities=uint2korr(end); if (pkt_length >= (uint) (end+18 - (char*) net->read_pos)) @@ -1712,6 +1653,13 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, mysql->server_language=end[2]; mysql->server_status=uint2korr(end+3); } + end+= 18; + if (pkt_length >= (uint) (end + SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323 + 1 - + (char *) net->read_pos)) + strmake(mysql->scramble+SCRAMBLE_LENGTH_323, end, + SCRAMBLE_LENGTH-SCRAMBLE_LENGTH_323); + else + mysql->server_capabilities&= ~CLIENT_SECURE_CONNECTION; /* Set character set */ if ((charset_name=mysql->options.charset_name)) @@ -1783,9 +1731,12 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, mysql->unix_socket=0; strmov(mysql->server_version,(char*) net->read_pos+1); mysql->port=port; - client_flag|=mysql->options.client_flag; - /* Send client information for access check */ + /* + Part 2: format and send client info to the server for access check + */ + + client_flag|=mysql->options.client_flag; client_flag|=CLIENT_CAPABILITIES; if (client_flag & CLIENT_MULTI_QUERIES) client_flag|= CLIENT_MULTI_RESULTS; @@ -1881,35 +1832,18 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, #include "_cust_libmysql.h" #endif DBUG_PRINT("info",("user: %s",end)); - /* - We always start with old type handshake the only difference is message sent - If server handles secure connection type we'll not send the real scramble - */ - if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + end= strend(end) + 1; + if (passwd[0]) { - if (passwd[0]) - { - /* Prepare false scramble */ - end=strend(end)+1; - bfill(end, SCRAMBLE_LENGTH, 'x'); - end+=SCRAMBLE_LENGTH; - *end=0; - } - else /* For empty password*/ - { - end=strend(end)+1; - *end=0; /* Store zero length scramble */ - } + /* Write NULL-terminated scrambled password: */ + end= mysql->server_capabilities & CLIENT_SECURE_CONNECTION ? + scramble(end, mysql->scramble, passwd) : + scramble_323(end, mysql->scramble_323, passwd, + (my_bool) (mysql->protocol_version == 9)); } else - { - /* - Real scramble is only sent to old servers. This can be blocked - by calling mysql_options(MYSQL *, MYSQL_SECURE_CONNECT, (char*) &1); - */ - end=scramble(strend(end)+1, mysql->scramble_buff, passwd, - (my_bool) (mysql->protocol_version == 9)); - } + *end= '\0'; /* empty password */ + /* Add database if needed */ if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB)) { @@ -1925,10 +1859,38 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, strmov(net->last_error,ER(net->last_errno)); goto error; } + + /* + Part 3: Authorization data's been sent. Now server can reply with + OK-packet, or re-request scrambled password. + */ - if (mysql_autenticate(mysql, passwd)) + if ((pkt_length=net_safe_read(mysql)) == packet_error) goto error; + if (net->read_pos[0] == mysql->scramble_323[0] && + pkt_length == SCRAMBLE_LENGTH_323 + 1 && + mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + { + /* + By sending this very specific reply server asks us to send scrambled + password in old format. The reply contains scramble_323. + */ + scramble_323(buff, mysql->scramble_323, passwd, + (my_bool) (mysql->protocol_version == 9)); + if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) + { + net->last_errno= CR_SERVER_LOST; + strmov(net->sqlstate, unknown_sqlstate); + strmov(net->last_error,ER(net->last_errno)); + goto error; + } + /* Read what server thinks about out new auth message report */ + if (net_safe_read(mysql) == packet_error) + goto error; + } + + if (client_flag & CLIENT_COMPRESS) /* We will use compression */ net->compress=1; diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index ae63ac85d4d..f8488565b75 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1346,95 +1346,33 @@ void Item_func_trim::fix_length_and_dec() } - - -void Item_func_password::fix_length_and_dec() -{ - /* - If PASSWORD() was called with only one argument, it depends on a random - number so we need to save this random number into the binary log. - If called with two arguments, it is repeatable. - */ - if (arg_count == 1) - { - THD *thd= current_thd; - thd->rand_used= 1; - thd->rand_saved_seed1= thd->rand.seed1; - thd->rand_saved_seed2= thd->rand.seed2; - } - max_length= get_password_length(use_old_passwords); -} - -/* - Password() function has 2 arguments. Second argument can be used - to make results repeatable -*/ +/* Item_func_password */ String *Item_func_password::val_str(String *str) { - struct rand_struct rand_st; // local structure for 2 param version - ulong seed=0; // seed to initialise random generator to - - String *res =args[0]->val_str(str); - if ((null_value=args[0]->null_value)) - return 0; - - if (arg_count == 1) - { - if (res->length() == 0) - return &empty_string; - make_scrambled_password(tmp_value,res->c_ptr(),use_old_passwords, - ¤t_thd->rand); - str->set(tmp_value,get_password_length(use_old_passwords),res->charset()); - return str; - } - else - { - /* We'll need the buffer to get second parameter */ - char key_buff[80]; - String tmp_key_value(key_buff, sizeof(key_buff), system_charset_info); - String *key =args[1]->val_str(&tmp_key_value); - - /* Check second argument for NULL value. First one is already checked */ - if ((null_value=args[1]->null_value)) - return 0; - - /* This shall be done after checking for null for proper results */ - if (res->length() == 0) - return &empty_string; - - /* Generate the seed first this allows to avoid double allocation */ - char* seed_ptr=key->c_ptr(); - while (*seed_ptr) - { - seed=(seed*211+*seed_ptr) & 0xffffffffL; /* Use simple hashing */ - seed_ptr++; - } - - /* Use constants which allow nice random values even with small seed */ - randominit(&rand_st, - (ulong) ((ulonglong) seed*111111+33333333L) & (ulong) 0xffffffff, - (ulong) ((ulonglong) seed*1111+55555555L) & (ulong) 0xffffffff); - - make_scrambled_password(tmp_value,res->c_ptr(),use_old_passwords, - &rand_st); - str->set(tmp_value,get_password_length(use_old_passwords),res->charset()); - return str; - } -} - -String *Item_func_old_password::val_str(String *str) -{ - String *res =args[0]->val_str(str); + String *res= args[0]->val_str(str); if ((null_value=args[0]->null_value)) return 0; if (res->length() == 0) return &empty_string; - make_scrambled_password(tmp_value,res->c_ptr(),1,¤t_thd->rand); - str->set(tmp_value,16,res->charset()); + make_scrambled_password(tmp_value, res->c_ptr()); + str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, res->charset()); return str; } +/* Item_func_old_password */ + +String *Item_func_old_password::val_str(String *str) +{ + String *res= args[0]->val_str(str); + if ((null_value=args[0]->null_value)) + return 0; + if (res->length() == 0) + return &empty_string; + make_scrambled_password_323(tmp_value, res->c_ptr()); + str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, res->charset()); + return str; +} #define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.') diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 6cc6d730627..11f5a66b3d1 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -254,30 +254,44 @@ public: }; +/* + Item_func_password -- new (4.1.1) PASSWORD() function implementation. + Returns strcat('*', octet2hex(sha1(sha1(password)))). '*' stands for new + password format, sha1(sha1(password) is so-called hash_stage2 value. + Length of returned string is always 41 byte. To find out how entire + authentification procedure works, see comments in password.c. +*/ + class Item_func_password :public Item_str_func { - char tmp_value[64]; /* This should be enough for new password format */ + char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; public: Item_func_password(Item *a) :Item_str_func(a) {} - Item_func_password(Item *a, Item *b) :Item_str_func(a,b) {} - String *val_str(String *); - void fix_length_and_dec(); + String *val_str(String *str); + void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; } const char *func_name() const { return "password"; } }; +/* + Item_func_old_password -- PASSWORD() implementation used in MySQL 3.21 - 4.0 + compatibility mode. This item is created in sql_yacc.yy when + 'use_old_passwords' session variable is set, and to handle OLD_PASSWORD() + function. +*/ + class Item_func_old_password :public Item_str_func { - char tmp_value[17]; /* old password length +1 */ + char tmp_value[SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1]; public: Item_func_old_password(Item *a) :Item_str_func(a) {} - String *val_str(String *); - void fix_length_and_dec() { max_length = get_password_length(1); } + String *val_str(String *str); + void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; } const char *func_name() const { return "old_password"; } + unsigned int size_of() { return sizeof(*this);} }; - class Item_func_des_encrypt :public Item_str_func { String tmp_value; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index aca84f1bcb3..13ff168e553 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -74,9 +74,6 @@ extern CHARSET_INFO *national_charset_info, *table_alias_charset; ****************************************************************************/ #define ACL_CACHE_SIZE 256 -/* Password lengh for 4.1 version previous versions had 16 bytes password hash */ -#define HASH_PASSWORD_LENGTH 45 -#define HASH_OLD_PASSWORD_LENGTH 16 #define HOST_CACHE_SIZE 128 #define MAX_ACCEPT_RETRY 10 // Test accept this many times #define MAX_FIELDS_BEFORE_HASH 32 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 72ee3e30c63..2677973ff0e 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2743,12 +2743,6 @@ static void create_new_thread(THD *thd) if (thread_count-delayed_insert_threads > max_used_connections) max_used_connections=thread_count-delayed_insert_threads; thd->thread_id=thread_id++; - for (uint i=0; i < 8 ; i++) // Generate password teststring - thd->scramble[i]= (char) (my_rnd(&sql_rand)*94+33); - thd->scramble[8]=0; - // Back it up as old clients may need it - memcpy(thd->old_scramble,thd->scramble,9); - thd->real_id=pthread_self(); // Keep purify happy diff --git a/sql/password.c b/sql/password.c index 257547671e5..be6514d89c6 100644 --- a/sql/password.c +++ b/sql/password.c @@ -29,28 +29,33 @@ The password is saved (in user.password) by using the PASSWORD() function in mysql. + This is .c file because it's used in libmysqlclient, which is entirely in C. + (we need it to be portable to a variety of systems). Example: update user set password=PASSWORD("hello") where user="test" This saves a hashed number as a string in the password field. + The new autentication is performed in following manner: - New in MySQL 4.1 authentication works even more secure way. - At the first step client sends user name to the sever, and password if - it is empty. So in case of empty password authentication is as fast as before. - At the second stap servers sends scramble to client, which is encoded with - password stage2 hash stored in the password database as well as salt, needed - for client to build stage2 password to decrypt scramble. - Client decrypts the scramble and encrypts it once again with stage1 password. - This information is sent to server. - Server decrypts the scramble to get stage1 password and hashes it to get - stage2 hash. This hash is when compared to hash stored in the database. + SERVER: public_seed=create_random_string() + send(public_seed) - This authentication needs 2 packet round trips instead of one but it is much - stronger. Now if one will steal mysql database content he will not be able - to break into MySQL. + CLIENT: recv(public_seed) + hash_stage1=sha1("password") + hash_stage2=sha1(hash_stage1) + reply=xor(hash_stage1, sha1(public_seed,hash_stage2) - New Password handling functions by Peter Zaitsev + // this three steps are done in scramble() + send(reply) + + + SERVER: recv(reply) + hash_stage1=xor(reply, sha1(public_seed,hash_stage2)) + candidate_hash2=sha1(hash_stage1) + check(candidate_hash2==hash_stage2) + + // this three steps are done in check_scramble() *****************************************************************************/ @@ -60,31 +65,21 @@ #include #include "mysql.h" - - -/* Character to use as version identifier for version 4.1 */ -#define PVERSION41_CHAR '*' - -/* Scramble length for new password version */ - +/************ MySQL 3.23-4.0 authentification routines: untouched ***********/ /* New (MySQL 3.21+) random generation structure initialization - SYNOPSIS randominit() rand_st OUT Structure to initialize seed1 IN First initialization parameter seed2 IN Second initialization parameter - - RETURN - none */ -void randominit(struct rand_struct *rand_st,ulong seed1, ulong seed2) -{ /* For mysql 3.21.# */ +void randominit(struct rand_struct *rand_st, ulong seed1, ulong seed2) +{ /* For mysql 3.21.# */ #ifdef HAVE_purify - bzero((char*) rand_st,sizeof(*rand_st)); /* Avoid UMC varnings */ + bzero((char*) rand_st,sizeof(*rand_st)); /* Avoid UMC varnings */ #endif rand_st->max_value= 0x3FFFFFFFL; rand_st->max_value_dbl=(double) rand_st->max_value; @@ -95,18 +90,15 @@ void randominit(struct rand_struct *rand_st,ulong seed1, ulong seed2) /* Old (MySQL 3.20) random generation structure initialization - + XXX: is to be deleted very soon! SYNOPSIS old_randominit() rand_st OUT Structure to initialize seed1 IN First initialization parameter - - RETURN - none */ -static void old_randominit(struct rand_struct *rand_st,ulong seed1) -{ /* For mysql 3.20.# */ +static void old_randominit(struct rand_struct *rand_st, ulong seed1) +{ /* For mysql 3.20.# */ rand_st->max_value= 0x01FFFFFFL; rand_st->max_value_dbl=(double) rand_st->max_value; seed1%=rand_st->max_value; @@ -115,14 +107,12 @@ static void old_randominit(struct rand_struct *rand_st,ulong seed1) /* - Generate Random number - + Generate random number. SYNOPSIS my_rnd() rand_st INOUT Structure used for number generation - - RETURN - Generated pseudo random number + RETURN VALUE + generated pseudo random number */ double my_rnd(struct rand_struct *rand_st) @@ -134,63 +124,12 @@ double my_rnd(struct rand_struct *rand_st) /* - Generate String of printable random characters of requested length - String will not be zero terminated. - + Generate binary hash from raw text string + Used for Pre-4.1 password handling SYNOPSIS - create_random_string() - length IN Lenght of - rand_st INOUT Structure used for number generation - target OUT Buffer for generation - - RETURN - none -*/ - -void create_random_string(int length,struct rand_struct *rand_st,char *target) -{ - char *end=target+length; - /* Use pointer arithmetics as it is faster way to do so. */ - for (; target0 -*/ - -int get_password_length(my_bool force_old_scramble) -{ - return (force_old_scramble) ? 16 : SHA1_HASH_SIZE*2+4+1; -} - - -/* - Get version of the password based on mysql.user password string - - SYNOPSIS - get_password_version() - password IN Password string as stored in mysql.user - - RETURN - 0 for pre 4.1 passwords - !0 password version char for newer passwords -*/ - -char get_password_version(const char *password) -{ - if (password==NULL) return 0; - if (password[0]==PVERSION41_CHAR) return PVERSION41_CHAR; - return 0; -} - - -/* - Get integer value of Hex character - - SYNOPSIS - char_val() - X IN Character to find value for - - RETURN - Appropriate integer value -*/ - - - -static inline unsigned int char_val(char X) -{ - return (uint) (X >= '0' && X <= '9' ? X-'0' : - X >= 'A' && X <= 'Z' ? X-'A'+10 : - X-'a'+10); -} - - -/* - Get Binary salt from password as in mysql.user format - - SYNOPSIS - get_salt_from_password() - res OUT Store binary salt here - password IN Password string as stored in mysql.user - - RETURN - none - - NOTE - This function does not have length check for passwords. It will just crash - Password hashes in old format must have length divisible by 8 -*/ - -void get_salt_from_password(ulong *res,const char *password) -{ - if (password) /* zero salt corresponds to empty password */ - { - if (password[0]==PVERSION41_CHAR) /* if new password */ - { - uint val=0; - uint i; - password++; /* skip version identifier */ - - /*get hashing salt from password and store in in the start of array */ - for (i=0 ; i < 4 ; i++) - val=(val << 4)+char_val(*password++); - *res++=val; - } - /* We process old passwords the same way as new ones in other case */ -#ifdef EXTRA_DEBUG - if (strlen(password)%8!=0) - fprintf(stderr,"Warning: Incorrect password length for salting: %d\n", - strlen(password)); -#endif - while (*password) - { - ulong val=0; - uint i; - for (i=0 ; i < 8 ; i++) - val=(val << 4)+char_val(*password++); - *res++=val; - } - } - return; -} - - -/* - Get string version as stored in mysql.user from salt form - - SYNOPSIS - make_password_from_salt() - to OUT Store resulting string password here - hash_res IN Password in salt format - password_version - IN According to which version salt should be treated - - RETURN - none -*/ - -void make_password_from_salt(char *to, ulong *hash_res,uint8 password_version) -{ - if (!password_version) /* Handling of old passwords. */ - sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]); - else - if (password_version==PVERSION41_CHAR) - sprintf(to,"%c%04x%08lx%08lx%08lx%08lx%08lx",PVERSION41_CHAR,(unsigned short)hash_res[0],hash_res[1], - hash_res[2],hash_res[3],hash_res[4],hash_res[5]); - else /* Just use empty password if we can't handle it. This should not happen */ - to[0]='\0'; -} - - -/* - Convert password in salted form to binary string password and hash-salt - For old password this involes one more hashing - - SYNOPSIS - get_hash_and_password() - salt IN Salt to convert from - pversion IN Password version to use - hash OUT Store zero ended hash here - bin_password OUT Store binary password here (no zero at the end) - - RETURN - 0 for pre 4.1 passwords - !0 password version char for newer passwords -*/ - -void get_hash_and_password(ulong *salt, uint8 pversion, char *hash, - unsigned char *bin_password) -{ - int t; - ulong* salt_end; - ulong val; - SHA1_CONTEXT context; - - if (pversion) /* New password version assumed */ - { - salt_end=salt+5; - sprintf(hash,"%04x",(unsigned short)salt[0]); - while (salt=0; t--) - { - bin_password[t]= (char) (val & 255); - val>>=8; /* Scroll 8 bits to get next part*/ - } - bin_password+=4; /* Get to next 4 chars*/ - } - } - else - { - unsigned char *bp= bin_password; /* Binary password loop pointer */ - - /* Use zero starting hash as an indication of old password */ - hash[0]=0; - salt_end=salt+2; - /* Encode salt using SHA1 here */ - sha1_reset(&context); - while (salt=0;t--) - { - bp[t]= (uchar) (val & 255); - val>>=8; /* Scroll 8 bits to get next part*/ - } - bp+= 4; /* Get to next 4 chars*/ - salt++; - } - /* Use 8 bytes of binary password for hash */ - sha1_input(&context,(uint8*)bin_password,8); - sha1_result(&context,(uint8*)bin_password); - } -} - - -/* - Create key from old password to decode scramble - Used in 4.1 authentication with passwords stored old way - - SYNOPSIS - create_key_from_old_password() - passwd IN Password used for key generation - key OUT Created 20 bytes key - - RETURN - None -*/ - - -void create_key_from_old_password(const char *passwd, char *key) -{ - char buffer[SCRAMBLE41_LENGTH]; /* Buffer for various needs */ - ulong salt[6]; /* Salt (large for safety) */ - /* At first hash password to the string stored in password */ - make_scrambled_password(buffer,passwd,1,(struct rand_struct *)NULL); - /* Now convert it to the salt form */ - get_salt_from_password(salt,buffer); - /* Finally get hash and bin password from salt */ - get_hash_and_password(salt,0,buffer,(unsigned char*) key); -} - - -/* - Scramble string with password - Used at pre 4.1 authentication phase. - - SYNOPSIS - scramble() - to OUT Store scrambled message here - message IN Message to scramble - password IN Password to use while scrambling - old_ver IN Forse old version random number generator - + scramble_323() + to OUT Store scrambled message here. Buffer must be at least + SCRAMBLE_LENGTH_323+1 bytes long + message IN Message to scramble. Message must be exactly + SRAMBLE_LENGTH_323 long and NULL terminated. + password IN Password to use while scrambling + old_ver IN Force old version random number generator RETURN End of scrambled string */ -char *scramble(char *to,const char *message,const char *password, - my_bool old_ver) +char *scramble_323(char *to, const char *message, const char *password, + my_bool old_ver) { struct rand_struct rand_st; - ulong hash_pass[2],hash_message[2]; - char message_buffer[9]; /* Real message buffer */ - char *msg=message_buffer; - - /* We use special message buffer now as new server can provide longer hash */ - - memcpy(message_buffer,message,8); - message_buffer[8]=0; + ulong hash_pass[2], hash_message[2]; if (password && password[0]) { char *to_start=to; hash_password(hash_pass,password); - hash_password(hash_message,message_buffer); + hash_password(hash_message, message); if (old_ver) old_randominit(&rand_st,hash_pass[0] ^ hash_message[0]); else randominit(&rand_st,hash_pass[0] ^ hash_message[0], - hash_pass[1] ^ hash_message[1]); - while (*msg++) + hash_pass[1] ^ hash_message[1]); + while (*message++) *to++= (char) (floor(my_rnd(&rand_st)*31)+64); if (!old_ver) - { /* Make it harder to break */ + { /* Make it harder to break */ char extra=(char) (floor(my_rnd(&rand_st)*31)); while (to_start != to) - *(to_start++)^=extra; + *(to_start++)^=extra; } } *to=0; @@ -666,49 +214,40 @@ char *scramble(char *to,const char *message,const char *password, /* - Check scrambled message - Used for pre 4.1 password handling - + Check scrambled message + Used in pre 4.1 password handling SYNOPSIS - scramble() - scrambled IN Scrambled message to check - message IN Original message which was scramble - hash_pass IN Password which should be used for scrambling - old_ver IN Forse old version random number generator - - RETURN - 0 Password correct - !0 Password invalid + check_scramble_323() + scrambled IN scrambled message to check. + message IN original random message which was used for scrambling; must + be exactly SCRAMBLED_LENGTH_323 bytes long and + NULL-terminated. + hash_pass IN password which should be used for scrambling + old_ver IN force old (3.20) version random number generator + RETURN VALUE + 0 - password correct + !0 - password invalid */ -my_bool check_scramble(const char *scrambled, const char *message, - ulong *hash_pass, my_bool old_ver) +my_bool +check_scramble_323(const char *scrambled, const char *message, + ulong *hash_pass, my_bool old_ver) { struct rand_struct rand_st; ulong hash_message[2]; - char buff[16],*to,extra; /* Big enough for check */ + char buff[16],*to,extra; /* Big enough for check */ const char *pos; - char message_buffer[SCRAMBLE_LENGTH+1]; /* Copy of message */ - - /* We need to copy the message as this function can be called for MySQL 4.1 - scramble which is not zero ended and can have zeroes inside - We could just write zero to proper place in original message but - this would make it harder to understand code for next generations - */ - - memcpy(message_buffer,message,SCRAMBLE_LENGTH); /* Ignore the rest */ - message_buffer[SCRAMBLE_LENGTH]=0; /* Check if this exactly N bytes. Overwise this is something fishy */ - if (strlen(message_buffer)!=SCRAMBLE_LENGTH) - return 1; /* Wrong password */ + if (strlen(message) != SCRAMBLE_LENGTH_323) + return 1; /* Wrong password */ - hash_password(hash_message,message_buffer); + hash_password(hash_message,message); if (old_ver) old_randominit(&rand_st,hash_pass[0] ^ hash_message[0]); else randominit(&rand_st,hash_pass[0] ^ hash_message[0], - hash_pass[1] ^ hash_message[1]); + hash_pass[1] ^ hash_message[1]); to=buff; for (pos=scrambled ; *pos ; pos++) *to++=(char) (floor(my_rnd(&rand_st)*31)+64); @@ -720,7 +259,300 @@ my_bool check_scramble(const char *scrambled, const char *message, while (*scrambled) { if (*scrambled++ != (char) (*to++ ^ extra)) - return 1; /* Wrong password */ + return 1; /* Wrong password */ } return 0; } + +static uint8 char_val(uint8 X) +{ + return (uint) (X >= '0' && X <= '9' ? X-'0' : + X >= 'A' && X <= 'Z' ? X-'A'+10 : X-'a'+10); +} + + +/* + Convert password from hex string (as stored in mysql.user) to binary form. + SYNOPSIS + get_salt_from_password_323() + res OUT store salt here + password IN password string as stored in mysql.user + NOTE + This function does not have length check for passwords. It will just crash + Password hashes in old format must have length divisible by 8 +*/ + +void get_salt_from_password_323(ulong *res, const char *password) +{ + res[0]= res[1]= 0; + if (password) + { + while (*password) + { + ulong val=0; + uint i; + for (i=0 ; i < 8 ; i++) + val=(val << 4)+char_val(*password++); + *res++=val; + } + } +} + + +/* + Convert scrambled password from binary form to asciiz hex string. + SYNOPSIS + make_password_from_salt_323() + to OUT store resulting string password here, at least 17 bytes + salt IN password in salt format, 2 ulongs +*/ + +void make_password_from_salt_323(char *to, const ulong *salt) +{ + sprintf(to,"%08lx%08lx", salt[0], salt[1]); +} + + +/******************* MySQL 4.1.1 authentification routines ******************/ +/* + Generate string of printable random characters of requested length + SYNOPSIS + create_random_string() + to OUT buffer for generation; must be at least length+1 bytes + long; result string is always null-terminated + length IN how many random characters to put in buffer + rand_st INOUT structure used for number generation +*/ + +void create_random_string(char *to, uint length, struct rand_struct *rand_st) +{ + char *end= to + length; + /* Use pointer arithmetics as it is faster way to do so. */ + for (; to < end; to++) + *to= (char) (my_rnd(rand_st)*94+33); + *to= '\0'; +} + + +/* Character to use as version identifier for version 4.1 */ + +#define PVERSION41_CHAR '*' + + +/* + Convert given octet sequence to asciiz string of hex characters; + str..str+len and 'to' may not overlap. + SYNOPSIS + octet2hex() + buf OUT output buffer. Must be at least 2*len+1 bytes + str, len IN the beginning and the length of the input string +*/ + +static +void +octet2hex(char *to, const uint8 *str, uint len) +{ + static const char alphabet[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + const uint8 *str_end= str + len; + for (; str != str_end; ++str) + { + *to++= alphabet[(*str & 0xF0) >> 4]; + *to++= alphabet[*str & 0x0F]; + } + *to++= '\0'; +} + + +/* + Convert given asciiz string of hex (0..9 a..f) characters to octet + sequence. + SYNOPSIS + hex2octet() + to OUT buffer to place result; must be at least len/2 bytes + str, len IN begin, length for character string; str and to may not + overlap; len % 2 == 0 +*/ + +static +void +hex2octet(uint8 *to, const char *str, uint len) +{ + const char *str_end= str + len; + while (str < str_end) + { + *to= char_val(*str++) << 4; + *to++|= char_val(*str++); + } +} + + +/* + Encrypt/Decrypt function used for password encryption in authentication. + Simple XOR is used here but it is OK as we crypt random strings. Note, + that XOR(s1, XOR(s1, s2)) == s2, XOR(s1, s2) == XOR(s2, s1) + SYNOPSIS + my_crypt() + to OUT buffer to hold crypted string; must be at least len bytes + long; to and s1 (or s2) may be the same. + s1, s2 IN input strings (of equal length) + len IN length of s1 and s2 +*/ + +static +void +my_crypt(char *to, const uint8 *s1, const uint8 *s2, uint len) +{ + const uint8 *s1_end= s1 + len; + while (s1 < s1_end) + *to++= *s1++ ^ *s2++; +} + + +/* + MySQL 4.1.1 password hashing: SHA conversion (see RFC 2289, 3174) twice + applied to the password string, and then produced octet sequence is + converted to hex string. + The result of this function is used as return value from PASSWORD() and + is stored in the database. + SYNOPSIS + make_scrambled_password() + buf OUT buffer of size 2*SHA1_HASH_SIZE + 2 to store hex string + password IN NULL-terminated password string +*/ + +void +make_scrambled_password(char *to, const char *password) +{ + SHA1_CONTEXT sha1_context; + uint8 hash_stage2[SHA1_HASH_SIZE]; + + sha1_reset(&sha1_context); + /* stage 1: hash password */ + sha1_input(&sha1_context, (uint8 *) password, strlen(password)); + sha1_result(&sha1_context, (uint8 *) to); + /* stage 2: hash stage1 output */ + sha1_reset(&sha1_context); + sha1_input(&sha1_context, (uint8 *) to, SHA1_HASH_SIZE); + /* separate buffer is used to pass 'to' in octet2hex */ + sha1_result(&sha1_context, hash_stage2); + /* convert hash_stage2 to hex string */ + *to++= PVERSION41_CHAR; + octet2hex(to, hash_stage2, SHA1_HASH_SIZE); +} + + +/* + Produce an obscure octet sequence from password and random + string, recieved from the server. This sequence corresponds to the + password, but password can not be easily restored from it. The sequence + is then sent to the server for validation. Trailing zero is stored in + the buf. + This function is used by client to create authenticated reply to the + server's greeting. + SYNOPSIS + scramble() + buf OUT store scrambled string here. The buf must be at least + SHA1_HASH_SIZE+1 bytes long. + message IN random message, must be exactly SCRAMBLE_LENGTH long and + NULL-terminated. + password IN users' password + RETURN VALUE + end of scrambled string +*/ + +char * +scramble(char *to, const char *message, const char *password) +{ + SHA1_CONTEXT sha1_context; + uint8 hash_stage1[SHA1_HASH_SIZE]; + uint8 hash_stage2[SHA1_HASH_SIZE]; + + sha1_reset(&sha1_context); + /* stage 1: hash password */ + sha1_input(&sha1_context, (uint8 *) password, strlen(password)); + sha1_result(&sha1_context, hash_stage1); + /* stage 2: hash stage 1; note that hash_stage2 is stored in the database */ + sha1_reset(&sha1_context); + sha1_input(&sha1_context, hash_stage1, SHA1_HASH_SIZE); + sha1_result(&sha1_context, hash_stage2); + /* create crypt string as sha1(message, hash_stage2) */; + sha1_reset(&sha1_context); + sha1_input(&sha1_context, (const uint8 *) message, SCRAMBLE_LENGTH); + sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE); + /* xor allows 'from' and 'to' overlap: lets take advantage of it */ + sha1_result(&sha1_context, (uint8 *) to); + my_crypt(to, (const uint8 *) to, hash_stage1, SCRAMBLE_LENGTH); + to[SHA1_HASH_SIZE]= '\0'; + return to + SHA1_HASH_SIZE; +} + + +/* + Check that scrambled message corresponds to the password; the function + is used by server to check that recieved reply is authentic. + This function does not check lengths of given strings: message must be + null-terminated, reply and hash_stage2 must be at least SHA1_HASH_SIZE + long (if not, something fishy is going on). + SYNOPSIS + check_scramble() + scramble IN clients' reply, presumably produced by scramble() + message IN original random string, previously sent to client + (presumably second argument of scramble()), must be + exactly SCRAMBLE_LENGTH long and NULL-terminated. + hash_stage2 IN hex2octet-decoded database entry + RETURN VALUE + 0 password is correct + !0 password is invalid +*/ + +my_bool +check_scramble(const char *scramble, const char *message, + const uint8 *hash_stage2) +{ + SHA1_CONTEXT sha1_context; + uint8 buf[SHA1_HASH_SIZE]; + uint8 hash_stage2_reassured[SHA1_HASH_SIZE]; + + sha1_reset(&sha1_context); + /* create key to encrypt scramble */ + sha1_input(&sha1_context, (const uint8 *) message, SCRAMBLE_LENGTH); + sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE); + sha1_result(&sha1_context, buf); + /* encrypt scramble */ + my_crypt((char *) buf, buf, (const uint8 *) scramble, SCRAMBLE_LENGTH); + /* now buf supposedly contains hash_stage1: so we can get hash_stage2 */ + sha1_reset(&sha1_context); + sha1_input(&sha1_context, buf, SHA1_HASH_SIZE); + sha1_result(&sha1_context, hash_stage2_reassured); + return memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE); +} + + +/* + Convert scrambled password from asciiz hex string to binary form. + SYNOPSIS + get_salt_from_password() + res OUT buf to hold password. Must be at least SHA1_HASH_SIZE + bytes long. + password IN 4.1.1 version value of user.password +*/ + +void get_salt_from_password(uint8 *hash_stage2, const char *password) +{ + hex2octet(hash_stage2, password+1 /* skip '*' */, SHA1_HASH_SIZE * 2); +} + +/* + Convert scrambled password from binary form to asciiz hex string. + SYNOPSIS + make_password_from_salt() + to OUT store resulting string here, 2*SHA1_HASH_SIZE+2 bytes + salt IN password in salt format +*/ + +void make_password_from_salt(char *to, const uint8 *hash_stage2) +{ + *to++= PVERSION41_CHAR; + octet2hex(to, hash_stage2, SHA1_HASH_SIZE); +} diff --git a/sql/slave.cc b/sql/slave.cc index c45c11f8bef..91376df5590 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1459,7 +1459,7 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname, if (master_user) strmake(mi->user, master_user, sizeof(mi->user) - 1); if (master_password) - strmake(mi->password, master_password, HASH_PASSWORD_LENGTH); + strmake(mi->password, master_password, SCRAMBLED_PASSWORD_CHAR_LENGTH); mi->port = master_port; mi->connect_retry = master_connect_retry; } @@ -1483,8 +1483,8 @@ int init_master_info(MASTER_INFO* mi, const char* master_info_fname, master_host) || init_strvar_from_file(mi->user, sizeof(mi->user), &mi->file, master_user) || - init_strvar_from_file(mi->password, HASH_PASSWORD_LENGTH+1, &mi->file, - master_password) || + init_strvar_from_file(mi->password, SCRAMBLED_PASSWORD_CHAR_LENGTH+1, + &mi->file, master_password) || init_intvar_from_file(&port, &mi->file, master_port) || init_intvar_from_file(&connect_retry, &mi->file, master_connect_retry)) diff --git a/sql/slave.h b/sql/slave.h index 429456eb0bb..d3565565ded 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -292,7 +292,7 @@ typedef struct st_master_info /* the variables below are needed because we can change masters on the fly */ char host[HOSTNAME_LENGTH+1]; char user[USERNAME_LENGTH+1]; - char password[HASH_PASSWORD_LENGTH+1]; + char password[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; pthread_mutex_t data_lock,run_lock; pthread_cond_t data_cond,start_cond,stop_cond; THD *io_thd; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 1bdca7167e8..bbc6b74c3a9 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -68,11 +68,36 @@ static ulong get_sort(uint count,...); static void init_check_host(void); static ACL_USER *find_acl_user(const char *host, const char *user); static bool update_user_table(THD *thd, const char *host, const char *user, - const char *new_password); + const char *new_password, uint new_password_len); static void update_hostname(acl_host_and_ip *host, const char *hostname); static bool compare_hostname(const acl_host_and_ip *host,const char *hostname, const char *ip); +/* + Convert scrambled password to binary form, according to scramble type, + Binary form is stored in user.salt. +*/ + +static +void +set_user_salt(ACL_USER *acl_user, const char *password, uint password_len) +{ + if (password_len == SCRAMBLED_PASSWORD_CHAR_LENGTH) + { + get_salt_from_password(acl_user->salt, password); + acl_user->salt_len= SCRAMBLE_LENGTH; + } + else if (password_len == SCRAMBLED_PASSWORD_CHAR_LENGTH_323 + || password_len == 8 && protocol_version == 9) + { + get_salt_from_password_323((ulong *) acl_user->salt, password); + acl_user->salt_len= password_len/2; + } + else + acl_user->salt_len= 0; +} + + /* Read grant privileges from the privilege tables in the 'mysql' database. @@ -175,16 +200,19 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) if (table->field[2]->field_length == 8 && protocol_version == PROTOCOL_VERSION) { - sql_print_error( - "Old 'user' table. (Check README or the Reference manual). Continuing --old-protocol"); /* purecov: tested */ + sql_print_error("Old 'user' table. " + "(Check README or the Reference manual). " + "Continuing --old-protocol"); /* purecov: tested */ protocol_version=9; /* purecov: tested */ } DBUG_PRINT("info",("user table fields: %d, password length: %d", table->fields, table->field[2]->field_length)); - if (table->field[2]->field_length < 45 && !use_old_passwords) + if (table->field[2]->field_length < 41 && !use_old_passwords) { - sql_print_error("mysql.user table is not updated to new password format; Disabling new password usage until mysql_fix_privilege_tables is run"); + sql_print_error("mysql.user table is not updated to new password format; " + "Disabling new password usage until " + "mysql_fix_privilege_tables is run"); use_old_passwords= 1; } @@ -192,83 +220,88 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) while (!(read_record_info.read_record(&read_record_info))) { ACL_USER user; - uint length=0; - update_hostname(&user.host,get_field(&mem, table->field[0])); - user.user=get_field(&mem, table->field[1]); - user.password=get_field(&mem, table->field[2]); - if (user.password && (length=(uint) strlen(user.password)) == 8 && - protocol_version == PROTOCOL_VERSION) + update_hostname(&user.host, get_field(&mem, table->field[0])); + user.user= get_field(&mem, table->field[1]); + const char *password= get_field(&mem, table->field[2]); + uint password_len= password ? strlen(password) : 0; + set_user_salt(&user, password, password_len); + if (user.salt_len == 0 && password_len != 0) { - sql_print_error( - "Found old style password for user '%s'. Ignoring user. (You may want to restart mysqld using --old-protocol)", - user.user ? user.user : ""); /* purecov: tested */ + switch (password_len) { + case 8: /* 3.20: to be removed */ + sql_print_error("Found old style password for user '%s'. " + "Ignoring user. (You may want to restart mysqld " + "using --old-protocol) ", + user.user ? user.user : ""); + break; + case 45: /* 4.1: to be removed */ + sql_print_error("Found 4.1 style password for user '%s'. " + "Ignoring user. " + "You should change password for this user.", + user.user ? user.user : ""); + break; + default: + sql_print_error("Found invalid password for user: '%s@%s'; " + "Ignoring user", user.user ? user.user : "", + user.host.hostname ? user.host.hostname : ""); + break; + } } - else /* non empty and not short passwords */ + else // password is correct { - user.pversion=get_password_version(user.password); - /* Only passwords of specific lengths depending on version are allowed */ - if ( (!user.pversion && length % 8) || (user.pversion && length!=45 )) + user.access= get_access(table,3) & GLOBAL_ACLS; + user.sort= get_sort(2,user.host.hostname,user.user); + user.hostname_length= (user.host.hostname ? + (uint) strlen(user.host.hostname) : 0); + if (table->fields >= 31) /* Starting from 4.0.2 we have more fields */ { - sql_print_error( - "Found invalid password for user: '%s@%s'; Ignoring user", - user.user ? user.user : "", - user.host.hostname ? user.host.hostname : ""); /* purecov: tested */ - continue; /* purecov: tested */ + char *ssl_type=get_field(&mem, table->field[24]); + if (!ssl_type) + user.ssl_type=SSL_TYPE_NONE; + else if (!strcmp(ssl_type, "ANY")) + user.ssl_type=SSL_TYPE_ANY; + else if (!strcmp(ssl_type, "X509")) + user.ssl_type=SSL_TYPE_X509; + else /* !strcmp(ssl_type, "SPECIFIED") */ + user.ssl_type=SSL_TYPE_SPECIFIED; + + user.ssl_cipher= get_field(&mem, table->field[25]); + user.x509_issuer= get_field(&mem, table->field[26]); + user.x509_subject= get_field(&mem, table->field[27]); + + char *ptr = get_field(&mem, table->field[28]); + user.user_resource.questions=atoi(ptr); + ptr = get_field(&mem, table->field[29]); + user.user_resource.updates=atoi(ptr); + ptr = get_field(&mem, table->field[30]); + user.user_resource.connections=atoi(ptr); + if (user.user_resource.questions || user.user_resource.updates || + user.user_resource.connections) + mqh_used=1; } - } - get_salt_from_password(user.salt,user.password); - user.access=get_access(table,3) & GLOBAL_ACLS; - user.sort=get_sort(2,user.host.hostname,user.user); - user.hostname_length= (user.host.hostname ? - (uint) strlen(user.host.hostname) : 0); - if (table->fields >= 31) /* Starting from 4.0.2 we have more fields */ - { - char *ssl_type=get_field(&mem, table->field[24]); - if (!ssl_type) - user.ssl_type=SSL_TYPE_NONE; - else if (!strcmp(ssl_type, "ANY")) - user.ssl_type=SSL_TYPE_ANY; - else if (!strcmp(ssl_type, "X509")) - user.ssl_type=SSL_TYPE_X509; - else /* !strcmp(ssl_type, "SPECIFIED") */ - user.ssl_type=SSL_TYPE_SPECIFIED; - - user.ssl_cipher= get_field(&mem, table->field[25]); - user.x509_issuer= get_field(&mem, table->field[26]); - user.x509_subject= get_field(&mem, table->field[27]); - - char *ptr = get_field(&mem, table->field[28]); - user.user_resource.questions=atoi(ptr); - ptr = get_field(&mem, table->field[29]); - user.user_resource.updates=atoi(ptr); - ptr = get_field(&mem, table->field[30]); - user.user_resource.connections=atoi(ptr); - if (user.user_resource.questions || user.user_resource.updates || - user.user_resource.connections) - mqh_used=1; - } - else - { - user.ssl_type=SSL_TYPE_NONE; - bzero(&(user.user_resource),sizeof(user.user_resource)); + else + { + user.ssl_type=SSL_TYPE_NONE; + bzero(&(user.user_resource),sizeof(user.user_resource)); #ifndef TO_BE_REMOVED - if (table->fields <= 13) - { // Without grant - if (user.access & CREATE_ACL) - user.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL; - } - /* Convert old privileges */ - user.access|= LOCK_TABLES_ACL | CREATE_TMP_ACL | SHOW_DB_ACL; - if (user.access & FILE_ACL) - user.access|= REPL_CLIENT_ACL | REPL_SLAVE_ACL; - if (user.access & PROCESS_ACL) - user.access|= SUPER_ACL | EXECUTE_ACL; + if (table->fields <= 13) + { // Without grant + if (user.access & CREATE_ACL) + user.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL; + } + /* Convert old privileges */ + user.access|= LOCK_TABLES_ACL | CREATE_TMP_ACL | SHOW_DB_ACL; + if (user.access & FILE_ACL) + user.access|= REPL_CLIENT_ACL | REPL_SLAVE_ACL; + if (user.access & PROCESS_ACL) + user.access|= SUPER_ACL | EXECUTE_ACL; #endif + } + VOID(push_dynamic(&acl_users,(gptr) &user)); + if (!user.host.hostname || user.host.hostname[0] == wild_many && + !user.host.hostname[1]) + allow_all_hosts=1; // Anyone can connect } - VOID(push_dynamic(&acl_users,(gptr) &user)); - if (!user.host.hostname || user.host.hostname[0] == wild_many && - !user.host.hostname[1]) - allow_all_hosts=1; // Anyone can connect } qsort((gptr) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements, sizeof(ACL_USER),(qsort_cmp) acl_compare); @@ -462,247 +495,203 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b) /* - Prepare crypted scramble to be sent to the client + Seek ACL entry for a user, check password, SSL cypher, and if + everything is OK, update THD user data and USER_RESOURCES struct. + This function does not check if the user has any sensible privileges: + only user's existence and validity is checked. + Note, that entire operation is protected by acl_cache_lock. + SYNOPSIS + thd INOUT thread handle. If all checks are OK, + thd->priv_user, thd->master_access are updated. + thd->host, thd->ip, thd->user are used for checks. + mqh OUT user resources; on success mqh is reset, else + unchanged + passwd IN scrambled & crypted password, recieved from client + (to check): thd->scramble or thd->scramble_323 is + used to decrypt passwd, so they must contain + original random string, + passwd_len IN length of passwd, must be one of 0, 8, + SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH + old_version IN if old (3.20) protocol is used + RETURN VALUE + 0 success: thread data and mqh are updated + 1 user not found or authentification failure + -1 user found, has short (3.23) salt, but passwd is in new (4.1.1) format. */ -void prepare_scramble(THD *thd, ACL_USER *acl_user,char* prepared_scramble) +int +acl_getroot(THD *thd, USER_RESOURCES *mqh, + const char *passwd, uint passwd_len, bool old_version) { - /* Binary password format to be used for generation*/ - char bin_password[SCRAMBLE41_LENGTH]; - /* Generate new long scramble for the thread */ - create_random_string(SCRAMBLE41_LENGTH,&thd->rand,thd->scramble); - thd->scramble[SCRAMBLE41_LENGTH]=0; - /* Get binary form, First 4 bytes of prepared scramble is salt */ - get_hash_and_password(acl_user->salt,acl_user->pversion,prepared_scramble, - (unsigned char*) bin_password); - /* Store "*" as identifier for old passwords */ - if (!acl_user->pversion) - prepared_scramble[0]='*'; - /* Finally encrypt password to get prepared scramble */ - password_crypt(thd->scramble, prepared_scramble+4, bin_password, - SCRAMBLE41_LENGTH); -} - - -/* - Get master privilges for user (priviliges for all tables). - Required before connecting to MySQL - - As we have 2 stage handshake now we cache user not to lookup - it second time. At the second stage we do not lookup user in case - we already know it; - -*/ - -ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, - const char *password,const char *message,char **priv_user, - char *priv_host, bool old_ver, USER_RESOURCES *mqh, - char *prepared_scramble, uint *cur_priv_version, - ACL_USER **cached_user) -{ - ulong user_access=NO_ACCESS; - *priv_user= (char*) user; - bool password_correct= 0; - int stage= (*cached_user != NULL); /* NULL passed as first stage */ - ACL_USER *acl_user= NULL; DBUG_ENTER("acl_getroot"); - bzero(mqh,sizeof(USER_RESOURCES)); - if (!initialized) - { - // If no data allow anything - DBUG_RETURN((ulong) ~NO_ACCESS); /* purecov: tested */ + if (!initialized) /* if no data allow anything */ + { + DBUG_RETURN(1); } + + int res= 1; + VOID(pthread_mutex_lock(&acl_cache->lock)); /* - Get possible access from user_list. This is or'ed to others not - fully specified - - If we have cached user use it, in other case look it up. + Find acl entry in user database. Note, that find_acl_user is not the same, + because it doesn't take into account the case when user is not empty, + but acl_user->user is empty */ - if (stage && (*cur_priv_version == priv_version)) - acl_user= *cached_user; - else + ACL_USER *acl_user= 0; + for (uint i=0 ; i < acl_users.elements ; i++) { - for (uint i=0 ; i < acl_users.elements ; i++) + ACL_USER *user_i = dynamic_element(&acl_users,i,ACL_USER*); + if (!user_i->user || !strcmp(thd->user, user_i->user)) { - ACL_USER *acl_user_search=dynamic_element(&acl_users,i,ACL_USER*); - if (!acl_user_search->user || !strcmp(user,acl_user_search->user)) + if (compare_hostname(&user_i->host, thd->host, thd->ip)) { - if (compare_hostname(&acl_user_search->host,host,ip)) + /* check password: it should be empty or valid */ + if (passwd_len == user_i->salt_len) { - /* Found mathing user */ - acl_user= acl_user_search; - /* Store it as a cache */ - *cached_user= acl_user; - *cur_priv_version= priv_version; - break; + if (user_i->salt_len == 0 || + user_i->salt_len == SCRAMBLE_LENGTH && + check_scramble(passwd, thd->scramble, user_i->salt) == 0 || + check_scramble_323(passwd, thd->scramble_323, + (ulong *) user_i->salt, old_version) == 0) + { + acl_user= user_i; + res= 0; + } } + else if (passwd_len == SCRAMBLE_LENGTH && + user_i->salt_len == SCRAMBLE_LENGTH_323) + res= -1; + /* linear search complete: */ + break; } } } - - /* Now we have acl_user found and may start our checks */ + /* + This was moved to separate tree because of heavy HAVE_OPENSSL case. + If acl_user is not null, res is 0. + */ if (acl_user) { - /* Password should present for both or absend for both */ - if (!acl_user->password && !*password) - password_correct=1; - else if (!acl_user->password || !*password) - { - *cached_user= 0; // Impossible to connect - } - else - { - /* New version password is checked differently */ - if (acl_user->pversion) - { - if (stage) /* We check password only on the second stage */ - { - if (!validate_password(password,message,acl_user->salt)) - password_correct=1; - } - else /* First stage - just prepare scramble */ - prepare_scramble(thd,acl_user,prepared_scramble); - } - /* Old way to check password */ - else - { - /* Checking the scramble at any stage. First - old clients */ - if (!check_scramble(password,message,acl_user->salt, - (my_bool) old_ver)) - password_correct=1; - else if (!stage) /* Here if password incorrect */ - { - /* At the first stage - prepare scramble */ - prepare_scramble(thd,acl_user,prepared_scramble); - } - } - } - } - - /* If user not found password_correct will also be zero */ - if (!password_correct) - goto unlock_and_exit; - - /* OK. User found and password checked continue validation */ - + /* OK. User found and password checked continue validation */ #ifdef HAVE_OPENSSL - { - Vio *vio=thd->net.vio; - /* - At this point we know that user is allowed to connect - from given host by given username/password pair. Now - we check if SSL is required, if user is using SSL and - if X509 certificate attributes are OK - */ - switch (acl_user->ssl_type) { - case SSL_TYPE_NOT_SPECIFIED: // Impossible - case SSL_TYPE_NONE: /* SSL is not required to connect */ - user_access=acl_user->access; - break; - case SSL_TYPE_ANY: /* Any kind of SSL is good enough */ - if (vio_type(vio) == VIO_TYPE_SSL) - user_access=acl_user->access; - break; - case SSL_TYPE_X509: /* Client should have any valid certificate. */ + { + ulong user_access= NO_ACCESS; + Vio *vio=thd->net.vio; /* - Connections with non-valid certificates are dropped already - in sslaccept() anyway, so we do not check validity here. - - We need to check for absence of SSL because without SSL - we should reject connection. + At this point we know that user is allowed to connect + from given host by given username/password pair. Now + we check if SSL is required, if user is using SSL and + if X509 certificate attributes are OK */ - if (vio_type(vio) == VIO_TYPE_SSL && SSL_get_peer_certificate(vio->ssl_)) - user_access=acl_user->access; - break; - case SSL_TYPE_SPECIFIED: /* Client should have specified attrib */ - /* - We do not check for absence of SSL because without SSL it does - not pass all checks here anyway. - If cipher name is specified, we compare it to actual cipher in - use. - */ - if (vio_type(vio) != VIO_TYPE_SSL) - break; - if (acl_user->ssl_cipher) - { - DBUG_PRINT("info",("comparing ciphers: '%s' and '%s'", - acl_user->ssl_cipher,SSL_get_cipher(vio->ssl_))); - if (!strcmp(acl_user->ssl_cipher,SSL_get_cipher(vio->ssl_))) - user_access=acl_user->access; - else - { - if (global_system_variables.log_warnings) - sql_print_error("X509 ciphers mismatch: should be '%s' but is '%s'", - acl_user->ssl_cipher, - SSL_get_cipher(vio->ssl_)); - user_access=NO_ACCESS; - break; - } + switch (acl_user->ssl_type) { + case SSL_TYPE_NOT_SPECIFIED: // Impossible + case SSL_TYPE_NONE: /* SSL is not required to connect */ + user_access=acl_user->access; + break; + case SSL_TYPE_ANY: /* Any kind of SSL is good enough */ + if (vio_type(vio) == VIO_TYPE_SSL) + user_access=acl_user->access; + break; + case SSL_TYPE_X509: /* Client should have any valid certificate. */ + /* + Connections with non-valid certificates are dropped already + in sslaccept() anyway, so we do not check validity here. + + We need to check for absence of SSL because without SSL + we should reject connection. + */ + if (vio_type(vio) == VIO_TYPE_SSL && + SSL_get_peer_certificate(vio->ssl_)) + user_access=acl_user->access; + break; + case SSL_TYPE_SPECIFIED: /* Client should have specified attrib */ + /* + We do not check for absence of SSL because without SSL it does + not pass all checks here anyway. + If cipher name is specified, we compare it to actual cipher in + use. + */ + if (vio_type(vio) != VIO_TYPE_SSL) + break; + if (acl_user->ssl_cipher) + { + DBUG_PRINT("info",("comparing ciphers: '%s' and '%s'", + acl_user->ssl_cipher,SSL_get_cipher(vio->ssl_))); + if (!strcmp(acl_user->ssl_cipher,SSL_get_cipher(vio->ssl_))) + user_access=acl_user->access; + else + { + if (global_system_variables.log_warnings) + sql_print_error("X509 ciphers mismatch: should be '%s'" + "but is '%s'", acl_user->ssl_cipher, + SSL_get_cipher(vio->ssl_)); + user_access=NO_ACCESS; + break; + } + } + /* Prepare certificate (if exists) */ + DBUG_PRINT("info",("checkpoint 1")); + X509* cert=SSL_get_peer_certificate(vio->ssl_); + DBUG_PRINT("info",("checkpoint 2")); + /* If X509 issuer is speified, we check it... */ + if (acl_user->x509_issuer) + { + DBUG_PRINT("info",("checkpoint 3")); + char *ptr = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); + DBUG_PRINT("info",("comparing issuers: '%s' and '%s'", + acl_user->x509_issuer, ptr)); + if (strcmp(acl_user->x509_issuer, ptr)) + { + if (global_system_variables.log_warnings) + sql_print_error("X509 issuer mismatch: should be '%s' " + "but is '%s'", acl_user->x509_issuer, ptr); + user_access=NO_ACCESS; + free(ptr); + break; + } + user_access=acl_user->access; + free(ptr); + } + DBUG_PRINT("info",("checkpoint 4")); + /* X509 subject is specified, we check it .. */ + if (acl_user->x509_subject) + { + char *ptr= X509_NAME_oneline(X509_get_subject_name(cert), 0, 0); + DBUG_PRINT("info",("comparing subjects: '%s' and '%s'", + acl_user->x509_subject, ptr)); + if (strcmp(acl_user->x509_subject,ptr)) + { + if (global_system_variables.log_warnings) + sql_print_error("X509 subject mismatch: '%s' vs '%s'", + acl_user->x509_subject, ptr); + user_access=NO_ACCESS; + } + else + user_access=acl_user->access; + free(ptr); + } + break; } - /* Prepare certificate (if exists) */ - DBUG_PRINT("info",("checkpoint 1")); - X509* cert=SSL_get_peer_certificate(vio->ssl_); - DBUG_PRINT("info",("checkpoint 2")); - /* If X509 issuer is speified, we check it... */ - if (acl_user->x509_issuer) - { - DBUG_PRINT("info",("checkpoint 3")); - char *ptr = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0); - DBUG_PRINT("info",("comparing issuers: '%s' and '%s'", - acl_user->x509_issuer, ptr)); - if (strcmp(acl_user->x509_issuer, ptr)) - { - if (global_system_variables.log_warnings) - sql_print_error("X509 issuer mismatch: should be '%s' but is '%s'", - acl_user->x509_issuer, ptr); - user_access=NO_ACCESS; - free(ptr); - break; - } - user_access=acl_user->access; - free(ptr); - } - DBUG_PRINT("info",("checkpoint 4")); - /* X509 subject is specified, we check it .. */ - if (acl_user->x509_subject) - { - char *ptr= X509_NAME_oneline(X509_get_subject_name(cert), 0, 0); - DBUG_PRINT("info",("comparing subjects: '%s' and '%s'", - acl_user->x509_subject, ptr)); - if (strcmp(acl_user->x509_subject,ptr)) - { - if (global_system_variables.log_warnings) - sql_print_error("X509 subject mismatch: '%s' vs '%s'", - acl_user->x509_subject, ptr); - user_access=NO_ACCESS; - } - else - user_access=acl_user->access; - free(ptr); - } - break; + /* end of SSL stuff: assign result */ + thd->master_access= user_access; } - } #else /* HAVE_OPENSSL */ - user_access=acl_user->access; + thd->master_access= acl_user->access; #endif /* HAVE_OPENSSL */ - *mqh=acl_user->user_resource; - if (!acl_user->user) - *priv_user=(char*) ""; // Change to anonymous user /* purecov: inspected */ + thd->priv_user= acl_user->user ? thd->user : (char *) ""; + *mqh= acl_user->user_resource; - if (acl_user->host.hostname) - strmake(priv_host, acl_user->host.hostname, MAX_HOSTNAME); - else - *priv_host= 0; - -unlock_and_exit: + if (acl_user->host.hostname) + strmake(thd->priv_host, acl_user->host.hostname, MAX_HOSTNAME); + else + *thd->priv_host= 0; + } VOID(pthread_mutex_unlock(&acl_cache->lock)); - DBUG_RETURN(user_access); + DBUG_RETURN(res); } @@ -713,8 +702,9 @@ static byte* check_get_key(ACL_USER *buff,uint *length, return (byte*) buff->host.hostname; } + static void acl_update_user(const char *user, const char *host, - const char *password, + const char *password, uint password_len, enum SSL_type ssl_type, const char *ssl_cipher, const char *x509_issuer, @@ -750,20 +740,9 @@ static void acl_update_user(const char *user, const char *host, acl_user->x509_subject= (x509_subject ? strdup_root(&mem,x509_subject) : 0); } - if (password) - { - if (!password[0]) /* If password is empty set it to null */ - { - acl_user->password=0; - acl_user->pversion=0; // just initialize - } - else - { - acl_user->password=(char*) ""; // Just point at something - get_salt_from_password(acl_user->salt,password); - acl_user->pversion=get_password_version(acl_user->password); - } - } + + set_user_salt(acl_user, password, password_len); + /* search complete: */ break; } } @@ -772,7 +751,7 @@ static void acl_update_user(const char *user, const char *host, static void acl_insert_user(const char *user, const char *host, - const char *password, + const char *password, uint password_len, enum SSL_type ssl_type, const char *ssl_cipher, const char *x509_issuer, @@ -783,7 +762,6 @@ static void acl_insert_user(const char *user, const char *host, ACL_USER acl_user; acl_user.user=strdup_root(&mem,user); update_hostname(&acl_user.host,strdup_root(&mem,host)); - acl_user.password=0; acl_user.access=privileges; acl_user.user_resource = *mqh; acl_user.sort=get_sort(2,acl_user.host.hostname,acl_user.user); @@ -793,12 +771,8 @@ static void acl_insert_user(const char *user, const char *host, acl_user.ssl_cipher= ssl_cipher ? strdup_root(&mem,ssl_cipher) : 0; acl_user.x509_issuer= x509_issuer ? strdup_root(&mem,x509_issuer) : 0; acl_user.x509_subject=x509_subject ? strdup_root(&mem,x509_subject) : 0; - if (password) - { - acl_user.password=(char*) ""; // Just point at something - get_salt_from_password(acl_user.salt,password); - acl_user.pversion=get_password_version(password); - } + + set_user_salt(&acl_user, password, password_len); VOID(push_dynamic(&acl_users,(gptr) &acl_user)); if (!acl_user.host.hostname || acl_user.host.hostname[0] == wild_many @@ -1135,7 +1109,6 @@ bool check_change_password(THD *thd, const char *host, const char *user) bool change_password(THD *thd, const char *host, const char *user, char *new_password) { - uint length=0; DBUG_ENTER("change_password"); DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'", host,user,new_password)); @@ -1144,37 +1117,27 @@ bool change_password(THD *thd, const char *host, const char *user, if (check_change_password(thd, host, user)) DBUG_RETURN(1); - /* - password should always be 0,16 or 45 chars; - Simple hack to avoid cracking - */ - length=(uint) strlen(new_password); - if (length != 45) - new_password[length & 16]=0; - VOID(pthread_mutex_lock(&acl_cache->lock)); ACL_USER *acl_user; - if (!(acl_user= find_acl_user(host,user))) + if (!(acl_user= find_acl_user(host, user))) { - send_error(thd, ER_PASSWORD_NO_MATCH); VOID(pthread_mutex_unlock(&acl_cache->lock)); + send_error(thd, ER_PASSWORD_NO_MATCH); DBUG_RETURN(1); } + /* update loaded acl entry: */ + uint new_password_len= new_password ? strlen(new_password) : 0; + set_user_salt(acl_user, new_password, new_password_len); + if (update_user_table(thd, acl_user->host.hostname ? acl_user->host.hostname : "", acl_user->user ? acl_user->user : "", - new_password)) + new_password, new_password_len)) { VOID(pthread_mutex_unlock(&acl_cache->lock)); /* purecov: deadcode */ send_error(thd,0); /* purecov: deadcode */ DBUG_RETURN(1); /* purecov: deadcode */ } - get_salt_from_password(acl_user->salt,new_password); - acl_user->pversion=get_password_version(new_password); - if (!new_password[0]) - acl_user->password=0; - else - acl_user->password=(char*) ""; // Point at something acl_cache->clear(1); // Clear locked hostname cache VOID(pthread_mutex_unlock(&acl_cache->lock)); @@ -1210,7 +1173,7 @@ find_acl_user(const char *host, const char *user) if (!acl_user->user && !user[0] || acl_user->user && !strcmp(user,acl_user->user)) { - if (compare_hostname(&(acl_user->host),host,host)) + if (compare_hostname(&acl_user->host,host,host)) { DBUG_RETURN(acl_user); } @@ -1280,7 +1243,7 @@ static bool compare_hostname(const acl_host_and_ip *host, const char *hostname, ****************************************************************************/ static bool update_user_table(THD *thd, const char *host, const char *user, - const char *new_password) + const char *new_password, uint new_password_len) { TABLE_LIST tables; TABLE *table; @@ -1304,7 +1267,7 @@ static bool update_user_table(THD *thd, const char *host, const char *user, DBUG_RETURN(1); /* purecov: deadcode */ } store_record(table,record[1]); - table->field[2]->store(new_password,(uint) strlen(new_password), &my_charset_latin1); + table->field[2]->store(new_password, new_password_len, &my_charset_latin1); if ((error=table->file->update_row(table->record[1],table->record[0]))) { table->file->print_error(error,MYF(0)); /* purecov: deadcode */ @@ -1352,24 +1315,24 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, { int error = -1; bool old_row_exists=0; - char *password,empty_string[1]; + char empty_string[]= { '\0' }; + char *password= empty_string; + uint password_len= 0; char what= (revoke_grant) ? 'N' : 'Y'; DBUG_ENTER("replace_user_table"); safe_mutex_assert_owner(&acl_cache->lock); - password=empty_string; - empty_string[0]=0; - if (combo.password.str && combo.password.str[0]) { - if ((combo.password.length != HASH_PASSWORD_LENGTH) - && combo.password.length != HASH_OLD_PASSWORD_LENGTH) + if (combo.password.length != SCRAMBLED_PASSWORD_CHAR_LENGTH && + combo.password.length != SCRAMBLED_PASSWORD_CHAR_LENGTH_323) { my_printf_error(ER_PASSWORD_NO_MATCH, "Password hash should be a %d-digit hexadecimal number", - MYF(0),HASH_PASSWORD_LENGTH); + MYF(0), SCRAMBLED_PASSWORD_CHAR_LENGTH); DBUG_RETURN(-1); } + password_len= combo.password.length; password=combo.password.str; } @@ -1394,17 +1357,20 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, goto end; } old_row_exists = 0; - restore_record(table,default_values); // cp empty row from default_values - table->field[0]->store(combo.host.str,combo.host.length, &my_charset_latin1); - table->field[1]->store(combo.user.str,combo.user.length, &my_charset_latin1); - table->field[2]->store(password,(uint) strlen(password), &my_charset_latin1); + restore_record(table,default_values); // cp empty row from default_values + table->field[0]->store(combo.host.str,combo.host.length, + &my_charset_latin1); + table->field[1]->store(combo.user.str,combo.user.length, + &my_charset_latin1); + table->field[2]->store(password, password_len, + &my_charset_latin1); } else { old_row_exists = 1; store_record(table,record[1]); // Save copy for update if (combo.password.str) // If password given - table->field[2]->store(password,(uint) strlen(password), &my_charset_latin1); + table->field[2]->store(password, password_len, &my_charset_latin1); } /* Update table columns with new privileges */ @@ -1501,10 +1467,8 @@ end: if (!error) { acl_cache->clear(1); // Clear privilege cache - if (!combo.password.str) - password=0; // No password given on command if (old_row_exists) - acl_update_user(combo.user.str,combo.host.str,password, + acl_update_user(combo.user.str, combo.host.str, password, password_len, thd->lex.ssl_type, thd->lex.ssl_cipher, thd->lex.x509_issuer, @@ -1512,7 +1476,7 @@ end: &thd->lex.mqh, rights); else - acl_insert_user(combo.user.str,combo.host.str,password, + acl_insert_user(combo.user.str, combo.host.str, password, password_len, thd->lex.ssl_type, thd->lex.ssl_cipher, thd->lex.x509_issuer, @@ -2915,12 +2879,15 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) global.append ("'@'",3); global.append(lex_user->host.str,lex_user->host.length); global.append ('\''); - if (acl_user->password) + if (acl_user->salt_len) { - char passd_buff[HASH_PASSWORD_LENGTH+1]; - make_password_from_salt(passd_buff,acl_user->salt,acl_user->pversion); + char passwd_buff[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; + if (acl_user->salt_len == SCRAMBLE_LENGTH) + make_password_from_salt(passwd_buff, acl_user->salt); + else + make_password_from_salt_323(passwd_buff, (ulong *) acl_user->salt); global.append(" IDENTIFIED BY PASSWORD '",25); - global.append(passd_buff); + global.append(passwd_buff); global.append('\''); } /* "show grants" SSL related stuff */ diff --git a/sql/sql_acl.h b/sql/sql_acl.h index e6c6771253c..3370797820a 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -111,9 +111,9 @@ public: acl_host_and_ip host; uint hostname_length; USER_RESOURCES user_resource; - char *user,*password; - ulong salt[6]; // New password has longer length - uint8 pversion; // password version + char *user; + uint8 salt[SCRAMBLE_LENGTH+1]; // scrambled password in binary form + uint8 salt_len; // 0 - no password, 4 - 3.20, 8 - 3.23, 20 - 4.1.1 enum SSL_type ssl_type; const char *ssl_cipher, *x509_issuer, *x509_subject; }; @@ -135,11 +135,8 @@ void acl_reload(THD *thd); void acl_free(bool end=0); ulong acl_get(const char *host, const char *ip, const char *bin_ip, const char *user, const char *db); -ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, - const char *password,const char *scramble, - char **priv_user, char *priv_host, - bool old_ver, USER_RESOURCES *max,char* prepared_scramble, - uint *cur_priv_version, ACL_USER **cached_user); +int acl_getroot(THD *thd, USER_RESOURCES *mqh, + const char *passwd, uint passwd_len, bool old_ver); bool acl_check_host(const char *host, const char *ip); bool check_change_password(THD *thd, const char *host, const char *user); bool change_password(THD *thd, const char *host, const char *user, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index c233ffd422a..ebb3e819ddc 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -139,6 +139,7 @@ THD::THD():user_time(0), is_fatal_error(0), set_query_id=1; db_access=NO_ACCESS; version=refresh_version; // For boot + *scramble= *scramble_323= '\0'; init(); /* Initialize sub structures */ diff --git a/sql/sql_class.h b/sql/sql_class.h index ccfe2555518..d962cc8086e 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -529,10 +529,16 @@ public: enum_tx_isolation session_tx_isolation; /* for user variables replication*/ DYNAMIC_ARRAY user_var_events; - // extend scramble to handle new auth - char scramble[SCRAMBLE41_LENGTH+1]; - // old scramble is needed to handle old clients - char old_scramble[SCRAMBLE_LENGTH+1]; + + /* scramble - random string sent to client on handshake */ + char scramble[SCRAMBLE_LENGTH+1]; + /* + The same as scramble but for old password checking routines. It always + contains first N bytes of scramble. + See check_connection() at sql_parse.cc for authentification details. + */ + char scramble_323[SCRAMBLE_LENGTH_323+1]; + uint8 query_cache_type; // type of query cache processing bool slave_thread; bool set_query_id,locked,count_cuted_fields,some_tables_deleted; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 5070466007e..384ec2bd4dd 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -178,152 +178,119 @@ end: /* - Check if user is ok - + Check if user exist and password supplied is correct. SYNOPSIS check_user() - thd Thread handle - command Command for connection (for log) - user Name of user trying to connect - passwd Scrambled password sent from client - db Database to connect to - check_count If set to 1, don't allow too many connection - simple_connect If 1 then client is of old type and we should connect - using the old method (no challange) - do_send_error Set to 1 if we should send error to user - prepared_scramble Buffer to store hash password of new connection - had_password Set to 1 if the user gave a password - cur_priv_version Check flag to know if someone flushed the privileges - since last code - hint_user Pointer used by acl_getroot() to remmeber user for - next call - - RETURN - 0 ok - thd->user, thd->master_access, thd->priv_user, thd->db and - thd->db_access are updated - 1 Access denied; Error sent to client - -1 If do_send_error == 1: Failed connect, error sent to client - If do_send_error == 0: Prepare for stage of connect + thd INOUT thread handle, thd->{host,user,ip} are used + command IN originator of the check: now check_user is called + during connect and change user procedures; used for + logging. + passwd IN scrambled password recieved from client + passwd_len IN length of scrambled password + db IN database name to connect to, may be NULL + check_count IN dont know exactly + Note, that host, user and passwd may point to communication buffer. + Current implementation does not depened on that, but future changes + should be done with this in mind. + RETURN VALUE + 0 OK; thd->user, thd->master_access, thd->priv_user, thd->db and + thd->db_access are updated; OK is sent to client; + 1 access denied or internal error; error is sent to client + Note, that this return semantics differs from check_connection, + which returns -1 if message was already sent. + -1 acl entry for this user contains old scramble, but passwd contains + new one, error is not sent to client */ -static int check_user(THD *thd,enum_server_command command, const char *user, - const char *passwd, const char *db, bool check_count, - bool simple_connect, bool do_send_error, - char *prepared_scramble, bool had_password, - uint *cur_priv_version, ACL_USER** hint_user) +static int check_user(THD *thd, enum enum_server_command command, + const char *passwd, uint passwd_len, const char *db, + bool check_count) { - thd->db=0; - thd->db_length=0; - USER_RESOURCES ur; - char tmp_passwd[SCRAMBLE41_LENGTH]; DBUG_ENTER("check_user"); - - /* - Move password to temporary buffer as it may be stored in communication - buffer - */ - strmake(tmp_passwd, passwd, sizeof(tmp_passwd)); - passwd= tmp_passwd; // Use local copy - - /* We shall avoid dupplicate user allocations here */ - if (!thd->user && !(thd->user = my_strdup(user, MYF(0)))) - { - send_error(thd,ER_OUT_OF_RESOURCES); - DBUG_RETURN(1); - } - thd->master_access=acl_getroot(thd, thd->host, thd->ip, thd->user, - passwd, thd->scramble, - &thd->priv_user, thd->priv_host, - (protocol_version == 9 || - !(thd->client_capabilities & - CLIENT_LONG_PASSWORD)), - &ur,prepared_scramble, - cur_priv_version,hint_user); - - DBUG_PRINT("info", - ("Capabilities: %d packet_length: %ld Host: '%s' Login user: '%s' Priv_user: '%s' Using password: %s Access: %u db: '%s'", - thd->client_capabilities, thd->max_client_packet_length, - thd->host_or_ip, thd->user, thd->priv_user, - had_password ? "yes": "no", - thd->master_access, thd->db ? thd->db : "*none*")); /* - In case we're going to retry we should not send error message at this - point + Why this is set here? - probably to reset current DB to 'no database + selected' in case of 'change user' failure. */ - if (thd->master_access & NO_ACCESS) + thd->db= 0; + thd->db_length= 0; + + USER_RESOURCES ur; + int res= acl_getroot(thd, &ur, passwd, passwd_len, + protocol_version == 9 || + !(thd->client_capabilities & CLIENT_LONG_PASSWORD)); + if (res == 0 && !(thd->master_access & NO_ACCESS)) // authentification is OK { - if (do_send_error || !had_password || !*hint_user) + DBUG_PRINT("info", + ("Capabilities: %d packet_length: %ld Host: '%s' " + "Login user: '%s' Priv_user: '%s' Using password: %s " + "Access: %u db: '%s'", + thd->client_capabilities, thd->max_client_packet_length, + thd->host_or_ip, thd->user, thd->priv_user, + passwd_len ? "yes": "no", + thd->master_access, thd->db ? thd->db : "*none*")); + + if (check_count) { - DBUG_PRINT("info",("Access denied")); - /* - Old client should get nicer error message if password version is - not supported - */ - if (simple_connect && *hint_user && (*hint_user)->pversion) - { - net_printf(thd, ER_NOT_SUPPORTED_AUTH_MODE); - mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE)); + VOID(pthread_mutex_lock(&LOCK_thread_count)); + bool count_ok= thread_count < max_connections + delayed_insert_threads || + thd->master_access & SUPER_ACL; + VOID(pthread_mutex_unlock(&LOCK_thread_count)); + if (!count_ok) + { // too many connections + send_error(thd, ER_CON_COUNT_ERROR); + DBUG_RETURN(1); } - else - { - net_printf(thd, ER_ACCESS_DENIED_ERROR, - thd->user, - thd->host_or_ip, - had_password ? ER(ER_YES) : ER(ER_NO)); - mysql_log.write(thd,COM_CONNECT,ER(ER_ACCESS_DENIED_ERROR), - thd->user, - thd->host_or_ip, - had_password ? ER(ER_YES) : ER(ER_NO)); - } - DBUG_RETURN(1); // Error already given } - DBUG_PRINT("info",("Prepare for second part of handshake")); - DBUG_RETURN(-1); // no report error in special handshake - } - if (check_count) - { - VOID(pthread_mutex_lock(&LOCK_thread_count)); - bool tmp=(thread_count - delayed_insert_threads >= max_connections && - !(thd->master_access & SUPER_ACL)); - VOID(pthread_mutex_unlock(&LOCK_thread_count)); - if (tmp) - { // Too many connections - send_error(thd, ER_CON_COUNT_ERROR); + /* Why logging is performed before all checks've passed? */ + mysql_log.write(thd,command, + (thd->priv_user == thd->user ? + (char*) "%s@%s on %s" : + (char*) "%s@%s as anonymous on %s"), + thd->user, thd->host_or_ip, + db ? db : (char*) ""); + + /* Why is it set here? */ + thd->db_access=0; + + /* Don't allow user to connect if he has done too many queries */ + if ((ur.questions || ur.updates || ur.connections) && + get_or_create_user_conn(thd,thd->user,thd->host_or_ip,&ur)) DBUG_RETURN(1); + if (thd->user_connect && thd->user_connect->user_resources.connections && + check_for_max_user_connections(thd, thd->user_connect)) + DBUG_RETURN(1); + + /* Change database if necessary: OK or FAIL is sent in mysql_change_db */ + if (db && db[0]) + { + if (mysql_change_db(thd, db)) + { + if (thd->user_connect) + decrease_user_connections(thd->user_connect); + DBUG_RETURN(1); + } } + else + send_ok(thd); + thd->password= test(passwd_len); // remember for error messages + /* Ready to handle queries */ } - mysql_log.write(thd,command, - (thd->priv_user == thd->user ? - (char*) "%s@%s on %s" : - (char*) "%s@%s as anonymous on %s"), - user, - thd->host_or_ip, - db ? db : (char*) ""); - thd->db_access=0; - /* Don't allow user to connect if he has done too many queries */ - if ((ur.questions || ur.updates || ur.connections) && - get_or_create_user_conn(thd,user,thd->host_or_ip,&ur)) - DBUG_RETURN(1); - if (thd->user_connect && thd->user_connect->user_resources.connections && - check_for_max_user_connections(thd, thd->user_connect)) - DBUG_RETURN(1); - - if (db && db[0]) + else if (res != -1) // authentication failure { - int error= test(mysql_change_db(thd,db)); - if (error && thd->user_connect) - decrease_user_connections(thd->user_connect); - DBUG_RETURN(error); + net_printf(thd, ER_ACCESS_DENIED_ERROR, + thd->user, + thd->host_or_ip, + passwd_len ? ER(ER_YES) : ER(ER_NO)); + mysql_log.write(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR), + thd->user, + thd->host_or_ip, + passwd_len ? ER(ER_YES) : ER(ER_NO)); } - send_ok(thd); // Ready to handle questions - thd->password= test(passwd[0]); // Remember for error messages - DBUG_RETURN(0); // ok + DBUG_RETURN(res); } - /* Check for maximum allowable user connections, if the mysqld server is started with corresponding variable that is greater then 0. @@ -525,48 +492,93 @@ static void reset_mqh(THD *thd, LEX_USER *lu, bool get_them= 0) /* - Check connnectionn and get priviliges - + Perform check for scrambled password, re-request scrambled password + from client if necessary. See also help for check_user. SYNOPSIS - check_connections - thd Thread handle + authenticate() + RETURN VALUE + 0 success, OK sent to client + -1 error, sent to client + > 0 error, not sent to client +*/ +static +int +authenticate(THD *thd, enum enum_server_command command, + const char *passwd, uint passwd_len, const char *db, + bool check_count) +{ + if (passwd_len != 0 && + passwd_len != SCRAMBLE_LENGTH && + passwd_len != SCRAMBLE_LENGTH_323) + return 1; + int res= check_user(thd, COM_CONNECT, passwd, passwd_len, db, check_count); + if (res < 0) + { + /* + This happens when client (new) sends password scrambled with + scramble(), but database holds old value (scrambled with + scramble_323()). Here we please client to send scrambled_password + in old format. + */ + char buff[NAME_LEN + 1]; + /* save db because network buffer is to hold new packet */ + if (db) + { + strmake(buff, db, NAME_LEN); + db= buff; + } + NET *net= &thd->net; + if (my_net_write(net, thd->scramble_323, SCRAMBLE_LENGTH_323 + 1) || + net_flush(net) || + my_net_read(net) != SCRAMBLE_LENGTH_323 + 1) // We have to read very + { // specific packet size + inc_host_errors(&thd->remote.sin_addr); + return ER_HANDSHAKE_ERROR; + } + /* Final attempt to check the user based on reply */ + /* So as passwd is short, errcode is always sent to user and res >= 0 */ + res= check_user(thd, COM_CONNECT, (char *) net->read_pos, + SCRAMBLE_LENGTH_323, db, check_count); + } + return res > 0 ? -1 : 0; +} + + +/* + Perform handshake, authorize client and update thd ACL variables. + SYNOPSIS + check_connection() + thd INOUT thread handle RETURN - 0 ok - -1 Error, which is sent to user - > 0 Error code (not sent to user) + 0 success, OK is sent to user + -1 error, which is sent to user + > 0 error code (not sent to user) */ #ifndef EMBEDDED_LIBRARY static int -check_connections(THD *thd) +check_connection(THD *thd) { - int res; - uint connect_errors=0; - uint cur_priv_version; - bool using_password; + uint connect_errors= 0; NET *net= &thd->net; - char *end, *user, *passwd, *db; - char prepared_scramble[SCRAMBLE41_LENGTH+4]; /* Buffer for scramble&hash */ - ACL_USER* cached_user=NULL; /* Initialise to NULL for first stage */ - DBUG_PRINT("info",("New connection received on %s", - vio_description(net->vio))); - /* Remove warning from valgrind. TODO: Fix it in password.c */ - bzero((char*) &prepared_scramble[0], sizeof(prepared_scramble)); + DBUG_PRINT("info", + ("New connection received on %s", vio_description(net->vio))); + if (!thd->host) // If TCP/IP connection { char ip[30]; if (vio_peer_addr(net->vio, ip, &thd->peer_port)) return (ER_BAD_HOST_ERROR); - if (!(thd->ip = my_strdup(ip,MYF(0)))) + if (!(thd->ip= my_strdup(ip,MYF(0)))) return (ER_OUT_OF_RESOURCES); - thd->host_or_ip=thd->ip; + thd->host_or_ip= thd->ip; #if !defined(HAVE_SYS_UN_H) || defined(HAVE_mit_thread) /* Fast local hostname resolve for Win32 */ if (!strcmp(thd->ip,"127.0.0.1")) - thd->host=(char*) localhost; + thd->host= (char *) localhost; else #endif { @@ -595,15 +607,16 @@ check_connections(THD *thd) DBUG_PRINT("info",("Host: %s",thd->host)); thd->host_or_ip= thd->host; thd->ip= 0; - bzero((char*) &thd->remote,sizeof(struct sockaddr)); + bzero((char*) &thd->remote, sizeof(struct sockaddr)); } /* Ensure that wrong hostnames doesn't cause buffer overflows */ vio_keepalive(net->vio, TRUE); - ulong pkt_len=0; + ulong pkt_len= 0; + char *end; { /* buff[] needs to big enough to hold the server_version variable */ - char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH+64]; + char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH + 64]; ulong client_flags = (CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB | CLIENT_PROTOCOL_41 | CLIENT_SECURE_CONNECTION); @@ -617,19 +630,36 @@ check_connections(THD *thd) client_flags |= CLIENT_SSL; /* Wow, SSL is avalaible! */ #endif /* HAVE_OPENSSL */ - end=strnmov(buff,server_version,SERVER_VERSION_LENGTH)+1; - int4store((uchar*) end,thd->thread_id); - end+=4; - memcpy(end,thd->scramble,SCRAMBLE_LENGTH+1); - end+=SCRAMBLE_LENGTH +1; - int2store(end,client_flags); - end[2]=(char) default_charset_info->number; - int2store(end+3,thd->server_status); - bzero(end+5,13); - end+=18; + end= strnmov(buff, server_version, SERVER_VERSION_LENGTH) + 1; + int4store((uchar*) end, thd->thread_id); + end+= 4; + /* + So as check_connection is the only entry point to authorization + procedure, scramble is set here. This gives us new scramble for + each handshake. + */ + create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand); + strmake(thd->scramble_323, thd->scramble, SCRAMBLE_LENGTH_323); - // At this point we write connection message and read reply - if (net_write_command(net,(uchar) protocol_version, "", 0, buff, + /* + Old clients does not understand long scrambles, but can ignore packet + tail: that's why first part of scramble is placed here, and second + part at the end of packet. + */ + end= strmake(end, thd->scramble_323, SCRAMBLE_LENGTH_323) + 1; + + int2store(end, client_flags); + /* write server characteristics: up to 16 bytes allowed */ + end[2]=(char) default_charset_info->number; + int2store(end+3, thd->server_status); + bzero(end+5, 13); + end+= 18; + /* write scramble tail */ + end= strmake(end, thd->scramble + SCRAMBLE_LENGTH_323, + SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323) + 1; + + /* At this point we write connection message and read reply */ + if (net_write_command(net, (uchar) protocol_version, "", 0, buff, (uint) (end-buff)) || (pkt_len= my_net_read(net)) == packet_error || pkt_len < MIN_HANDSHAKE_SIZE) @@ -702,7 +732,7 @@ check_connections(THD *thd) return(ER_HANDSHAKE_ERROR); } DBUG_PRINT("info", ("Reading user information over SSL layer")); - if ((pkt_len=my_net_read(net)) == packet_error || + if ((pkt_len= my_net_read(net)) == packet_error || pkt_len < NORMAL_HANDSHAKE_SIZE) { DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)", @@ -719,16 +749,7 @@ check_connections(THD *thd) return(ER_HANDSHAKE_ERROR); } - user= end; - passwd= strend(user)+1; - db=0; - using_password= test(passwd[0]); - if (thd->client_capabilities & CLIENT_CONNECT_WITH_DB) - db=strend(passwd)+1; - - /* We can get only old hash at this point */ - if (using_password && strlen(passwd) != SCRAMBLE_LENGTH) - return ER_HANDSHAKE_ERROR; + /* why has it been put here? */ if (thd->client_capabilities & CLIENT_INTERACTIVE) thd->variables.net_wait_timeout= thd->variables.net_interactive_timeout; @@ -737,60 +758,19 @@ check_connections(THD *thd) net->return_status= &thd->server_status; net->read_timeout=(uint) thd->variables.net_read_timeout; - /* Simple connect only for old clients. New clients always use secure auth */ - bool simple_connect=(!(thd->client_capabilities & CLIENT_SECURE_CONNECTION)); + char *user= end; + char *passwd= strend(user)+1; + uint passwd_len= strlen(passwd); - /* Check user permissions. If password failure we'll get scramble back */ - if ((res=check_user(thd, COM_CONNECT, user, passwd, db, 1, simple_connect, - simple_connect, prepared_scramble, using_password, - &cur_priv_version, - &cached_user)) < 0) - { - /* Store current used and database as they are erased with next packet */ - char tmp_user[USERNAME_LENGTH+1]; - char tmp_db[NAME_LEN+1]; + char *db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? + passwd+passwd_len+1 : 0; - /* If the client is old we just have to return error */ - if (simple_connect) - return -1; - - DBUG_PRINT("info",("password challenge")); - - tmp_user[0]= tmp_db[0]= 0; - if (user) - strmake(tmp_user,user,USERNAME_LENGTH); - if (db) - strmake(tmp_db,db,NAME_LEN); - - /* Write hash and encrypted scramble to client */ - if (my_net_write(net,prepared_scramble,SCRAMBLE41_LENGTH+4) || - net_flush(net)) - { - inc_host_errors(&thd->remote.sin_addr); - return ER_HANDSHAKE_ERROR; - } - /* Reading packet back */ - if ((pkt_len= my_net_read(net)) == packet_error) - { - inc_host_errors(&thd->remote.sin_addr); - return ER_HANDSHAKE_ERROR; - } - /* We have to get very specific packet size */ - if (pkt_len != SCRAMBLE41_LENGTH) - { - inc_host_errors(&thd->remote.sin_addr); - return ER_HANDSHAKE_ERROR; - } - /* Final attempt to check the user based on reply */ - if (check_user(thd,COM_CONNECT, tmp_user, (char*)net->read_pos, - tmp_db, 1, 0, 1, prepared_scramble, using_password, - &cur_priv_version, - &cached_user)) - return -1; - } - else if (res) - return -1; // Error sent from check_user() - return 0; + if (thd->user) + x_free(thd->user); + thd->user= my_strdup(user, MYF(0)); + if (!thd->user) + return(ER_OUT_OF_RESOURCES); + return authenticate(thd, COM_CONNECT, passwd, passwd_len, db, true); } @@ -847,7 +827,7 @@ pthread_handler_decl(handle_one_connection,arg) NET *net= &thd->net; thd->thread_stack= (char*) &thd; - if ((error=check_connections(thd))) + if ((error=check_connection(thd))) { // Wrong permissions if (error > 0) net_printf(thd,error,thd->host_or_ip); @@ -1152,116 +1132,60 @@ bool dispatch_command(enum enum_server_command command, THD *thd, case COM_CHANGE_USER: { thd->change_user(); - thd->clear_error(); // If errors from rollback + thd->clear_error(); // if errors from rollback - statistic_increment(com_other,&LOCK_status); - char *user= (char*) packet; + statistic_increment(com_other, &LOCK_status); + char *user= (char*) packet; char *passwd= strend(user)+1; - char *db= strend(passwd)+1; + uint passwd_len= strlen(passwd); + char *db= passwd + passwd_len + 1; + + /* Small check for incomming packet */ + if ((uint) ((uchar*) db - net->read_pos) > packet_length) + { + send_error(thd, ER_UNKNOWN_COM_ERROR); + break; + } /* Save user and privileges */ - uint save_master_access=thd->master_access; - uint save_db_access= thd->db_access; - uint save_db_length= thd->db_length; - char *save_user= thd->user; - thd->user=NULL; /* Needed for check_user to allocate new user */ - char *save_priv_user= thd->priv_user; - char *save_db= thd->db; - USER_CONN *save_uc= thd->user_connect; - bool simple_connect; - bool using_password; - char prepared_scramble[SCRAMBLE41_LENGTH+4];/* Buffer for scramble,hash */ - char tmp_user[USERNAME_LENGTH+1]; - char tmp_db[NAME_LEN+1]; - ACL_USER* cached_user ; /* Cached user */ - uint cur_priv_version; /* Cached grant version */ - int res; - ulong pkt_len= 0; /* Length of reply packet */ - - bzero((char*) prepared_scramble, sizeof(prepared_scramble)); - /* Small check for incomming packet */ - - if ((uint) ((uchar*) db - net->read_pos) > packet_length) - goto restore_user_err; - - /* Now we shall basically perform authentication again */ - - /* We can get only old hash at this point */ - if (passwd[0] && strlen(passwd)!=SCRAMBLE_LENGTH) - goto restore_user_err; - - cached_user= NULL; - - /* Simple connect only for old clients. New clients always use sec. auth*/ - simple_connect=(!(thd->client_capabilities & CLIENT_SECURE_CONNECTION)); - - /* Store information if we used password. passwd will be dammaged */ - using_password=test(passwd[0]); - - if (simple_connect) /* Restore scramble for old clients */ - memcpy(thd->scramble,thd->old_scramble,9); - - /* - Check user permissions. If password failure we'll get scramble back - Do not retry if we already have sent error (result>0) - */ - if ((res=check_user(thd,COM_CHANGE_USER, user, passwd, db, 0, - simple_connect, simple_connect, prepared_scramble, - using_password, &cur_priv_version, &cached_user)) < 0) + uint save_master_access= thd->master_access; + uint save_db_access= thd->db_access; + uint save_db_length= thd->db_length; + char *save_user= thd->user; + char *save_priv_user= thd->priv_user; + char *save_db= thd->db; + USER_CONN *save_uc= thd->user_connect; + thd->user= my_strdup(user, MYF(0)); + if (!thd->user) { - /* If the client is old we just have to have auth failure */ - if (simple_connect) - goto restore_user; /* Error is already reported */ - - /* Store current used and database as they are erased with next packet */ - tmp_user[0]= tmp_db[0]= 0; - if (user) - strmake(tmp_user,user,USERNAME_LENGTH); - if (db) - strmake(tmp_db,db,NAME_LEN); - - /* Write hash and encrypted scramble to client */ - if (my_net_write(net,prepared_scramble,SCRAMBLE41_LENGTH+4) || - net_flush(net)) - goto restore_user_err; - - /* Reading packet back */ - if ((pkt_len=my_net_read(net)) == packet_error) - goto restore_user_err; - - /* We have to get very specific packet size */ - if (pkt_len != SCRAMBLE41_LENGTH) - goto restore_user; - - /* Final attempt to check the user based on reply */ - if (check_user(thd,COM_CHANGE_USER, tmp_user, (char*) net->read_pos, - tmp_db, 0, 0, 1, prepared_scramble, using_password, - &cur_priv_version, &cached_user)) - goto restore_user; + thd->user= save_user; + send_error(thd, ER_OUT_OF_RESOURCES); + break; } - else if (res) - goto restore_user; - /* Finally we've authenticated new user */ - if (max_connections && save_uc) - decrease_user_connections(save_uc); - x_free((gptr) save_db); - x_free((gptr) save_user); - thd->password=using_password; - break; + int res= authenticate(thd, COM_CHANGE_USER, passwd, passwd_len, db, false); - /* Bad luck we shall restore old user */ -restore_user_err: - send_error(thd, ER_UNKNOWN_COM_ERROR); - -restore_user: - x_free(thd->user); - thd->master_access=save_master_access; - thd->db_access=save_db_access; - thd->db=save_db; - thd->db_length=save_db_length; - thd->user=save_user; - thd->priv_user=save_priv_user; + if (res) + { + /* authentification failure, we shall restore old user */ + if (res > 0) + send_error(thd, ER_UNKNOWN_COM_ERROR); + x_free(thd->user); + thd->user= save_user; + thd->priv_user= save_priv_user; + thd->master_access= save_master_access; + thd->db_access= save_db_access; + thd->db= save_db; + thd->db_length= save_db_length; + } + else + { + /* we've authenticated new user */ + if (max_connections && save_uc) + decrease_user_connections(save_uc); + x_free((gptr) save_db); + x_free((gptr) save_user); + } break; } #endif /* EMBEDDED_LIBRARY */ @@ -3158,7 +3082,7 @@ error: Check grants for commands which work only with one table and all other tables belong to subselects. - SYNOPSYS + SYNOPSIS single_table_command_access() thd - Thread handler privilege - asked privelage diff --git a/sql/sql_repl.h b/sql/sql_repl.h index e3d600b9798..b53551845bc 100644 --- a/sql/sql_repl.h +++ b/sql/sql_repl.h @@ -7,7 +7,7 @@ typedef struct st_slave_info uint32 rpl_recovery_rank, master_id; char host[HOSTNAME_LENGTH+1]; char user[USERNAME_LENGTH+1]; - char password[HASH_PASSWORD_LENGTH+1]; + char password[SCRAMBLED_PASSWORD_CHAR_LENGTH+1]; uint16 port; THD* thd; } SLAVE_INFO; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 1d605abe8a3..c8c9eb97a6a 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2515,9 +2515,10 @@ simple_expr: | NOW_SYM '(' expr ')' { $$= new Item_func_now($3); Lex->safe_to_cache_query=0;} | PASSWORD '(' expr ')' - { $$= new Item_func_password($3); } - | PASSWORD '(' expr ',' expr ')' - { $$= new Item_func_password($3,$5); } + { + $$= use_old_passwords ? (Item *) new Item_func_old_password($3) : + (Item *) new Item_func_password($3); + } | POINT_SYM '(' expr ',' expr ')' { $$= new Item_func_point($3,$5); } | POINTFROMTEXT '(' expr ')' @@ -4604,13 +4605,22 @@ text_or_password: { if (!$3.length) $$=$3.str; - else + else if (use_old_passwords) { - char *buff=(char*) YYTHD->alloc(HASH_PASSWORD_LENGTH+1); - make_scrambled_password(buff,$3.str,use_old_passwords, - &YYTHD->rand); + char *buff= (char *) + YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); + if (buff) + make_scrambled_password_323(buff, $3.str); $$=buff; } + else + { + char *buff= (char *) + YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); + if (buff) + make_scrambled_password(buff, $3.str); + $$=buff; + } } ; @@ -4918,14 +4928,24 @@ grant_user: $$=$1; $1->password=$4; if ($4.length) { - char *buff=(char*) YYTHD->alloc(HASH_PASSWORD_LENGTH+1); - if (buff) - { - make_scrambled_password(buff,$4.str,use_old_passwords, - &YYTHD->rand); - $1->password.str=buff; - $1->password.length=HASH_PASSWORD_LENGTH; - } + if (use_old_passwords) + { + char *buff= + (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); + if (buff) + make_scrambled_password_323(buff, $4.str); + $1->password.str= buff; + $1->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; + } + else + { + char *buff= + (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); + if (buff) + make_scrambled_password(buff, $4.str); + $1->password.str= buff; + $1->password.length= SCRAMBLED_PASSWORD_CHAR_LENGTH; + } } } | user IDENTIFIED_SYM BY PASSWORD TEXT_STRING From ccbcf1c9da89eaee2dfb4219da1d86b6f590ac20 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 4 Jul 2003 20:52:04 +0400 Subject: [PATCH 002/282] Bug fixes for authentication OLD_PASSWORD made a keyword to allow set password=old_password('abc') constructions. BitKeeper/etc/ignore: Added BitKeeper/post-commit BitKeeper/post-commit-manual build_tags.sh tests/connect_test BUILD/compile-pentium-maintainer to the ignore list include/mysql_com.h: scramble return type changed to void as now it's not used libmysql/libmysql.c: fixed bug with with failed authentification when scramble contained zero byte sql-common/client.c: applied patch from Lycos team fixed bug with scramble containing zero byte sql/item_create.cc: removed create_func_old_password, create_func_password as they are not used any more sql/item_create.h: removed create_func_old_password, create_func_password as they are not used any more sql/item_strfunc.cc: Added alloc() function to Item_func_password, Item_func_old_password, which is used in sql_yacc.yy sql/item_strfunc.h: Added alloc() function to Item_func_password, Item_func_old_password, which is used in sql_yacc.yy sql/lex.h: OLD_PASSWORD now is keyword, to allow statements like set password=old_password('abc') sql/password.c: fixed scramble return value trailing zero now is not written sql/sql_acl.cc: incorporated patch from Lycos team 41 replaced with constant acl_getroot rewritten to support ER_AUTH_... error sql/sql_parse.cc: authenticate merged with check_user check_user return values reversed, support for ER_AUTH in check_user.added sql/sql_yacc.yy: OLD_PASSWORD now is keyword, to allow statements like set password=old_password('abc') --- .bzrignore | 5 + include/mysql_com.h | 2 +- libmysql/libmysql.c | 18 ++-- sql-common/client.c | 24 +++-- sql/item_create.cc | 12 --- sql/item_create.h | 2 - sql/item_strfunc.cc | 16 +++ sql/item_strfunc.h | 3 +- sql/lex.h | 2 +- sql/password.c | 12 +-- sql/sql_acl.cc | 9 +- sql/sql_parse.cc | 256 ++++++++++++++++++++++---------------------- sql/sql_yacc.yy | 37 +++---- 13 files changed, 204 insertions(+), 194 deletions(-) diff --git a/.bzrignore b/.bzrignore index a23384d4170..7c0a871a951 100644 --- a/.bzrignore +++ b/.bzrignore @@ -624,3 +624,8 @@ vio/test-sslserver vio/viotest-ssl start_mysqld.sh mysys/main.cc +BitKeeper/post-commit +BitKeeper/post-commit-manual +build_tags.sh +tests/connect_test +BUILD/compile-pentium-maintainer diff --git a/include/mysql_com.h b/include/mysql_com.h index c1f18160667..784a7782855 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -327,7 +327,7 @@ void get_salt_from_password_323(unsigned long *res, const char *password); void make_password_from_salt_323(char *to, const unsigned long *salt); void make_scrambled_password(char *to, const char *password); -char *scramble(char *to, const char *message, const char *password); +void scramble(char *to, const char *message, const char *password); my_bool check_scramble(const char *reply, const char *message, const unsigned char *hash_stage2); void get_salt_from_password(unsigned char *res, const char *password); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 6bc38abb060..8b83343df8f 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -619,16 +619,20 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, /* write scrambled password according to server capabilities */ if (passwd[0]) { - /* Write NULL-terminated scrambled password: */ - end= mysql->server_capabilities & CLIENT_SECURE_CONNECTION ? - scramble(end, mysql->scramble, passwd) : - scramble_323(end, mysql->scramble_323, passwd, - (my_bool) (mysql->protocol_version == 9)); + if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + { + *end++= SCRAMBLE_LENGTH; + scramble(end, mysql->scramble, passwd); + end+= SCRAMBLE_LENGTH; + } + else + end= scramble_323(end, mysql->scramble_323, passwd, + (my_bool) (mysql->protocol_version == 9)) + 1; } else - *end= '\0'; // empty password + *end++= '\0'; // empty password /* Add database if needed */ - end=strmov(end+1,db ? db : ""); + end= strmov(end, db ? db : "") + 1; /* Write authentication package */ simple_command(mysql,COM_CHANGE_USER, buff,(ulong) (end-buff),1); diff --git a/sql-common/client.c b/sql-common/client.c index 35dea62edc3..efb71021f8d 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1823,7 +1823,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, mysql->server_status, client_flag)); /* This needs to be changed as it's not useful with big packets */ if (user && user[0]) - strmake(end,user,32); /* Max user name */ + strmake(end,user,USERNAME_LENGTH); /* Max user name */ else read_user_name((char*) end); @@ -1835,21 +1835,25 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, end= strend(end) + 1; if (passwd[0]) { - /* Write NULL-terminated scrambled password: */ - end= mysql->server_capabilities & CLIENT_SECURE_CONNECTION ? - scramble(end, mysql->scramble, passwd) : - scramble_323(end, mysql->scramble_323, passwd, - (my_bool) (mysql->protocol_version == 9)); + if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) + { + *end++= SCRAMBLE_LENGTH; + scramble(end, mysql->scramble, passwd); + end+= SCRAMBLE_LENGTH; + } + else + end= scramble_323(end, mysql->scramble_323, passwd, + (my_bool) (mysql->protocol_version == 9)) + 1; } else - *end= '\0'; /* empty password */ + *end++= '\0'; /* empty password */ /* Add database if needed */ if (db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB)) { - end=strmake(end+1,db,NAME_LEN); - mysql->db=my_strdup(db,MYF(MY_WME)); - db=0; + end= strmake(end, db, NAME_LEN) + 1; + mysql->db= my_strdup(db,MYF(MY_WME)); + db= 0; } /* Write authentication package */ if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net)) diff --git a/sql/item_create.cc b/sql/item_create.cc index 90f42cee959..fbb26e83dfd 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -52,13 +52,6 @@ Item *create_func_ord(Item* a) return new Item_func_ord(a); } -Item *create_func_old_password(Item* a) -{ - return new Item_func_old_password(a); -} - - - Item *create_func_asin(Item* a) { return new Item_func_asin(a); @@ -332,11 +325,6 @@ Item *create_func_quarter(Item* a) return new Item_func_quarter(a); } -Item *create_func_password(Item* a) -{ - return new Item_func_password(a); -} - Item *create_func_radians(Item *a) { return new Item_func_units((char*) "radians",a,M_PI/180,0.0); diff --git a/sql/item_create.h b/sql/item_create.h index 4151f59a87f..2872451c034 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -69,14 +69,12 @@ Item *create_func_monthname(Item* a); Item *create_func_nullif(Item* a, Item *b); Item *create_func_oct(Item *); Item *create_func_ord(Item* a); -Item *create_func_old_password(Item* a); Item *create_func_period_add(Item* a, Item *b); Item *create_func_period_diff(Item* a, Item *b); Item *create_func_pi(void); Item *create_func_pow(Item* a, Item *b); Item *create_func_current_user(void); Item *create_func_quarter(Item* a); -Item *create_func_password(Item* a); Item *create_func_radians(Item *a); Item *create_func_release_lock(Item* a); Item *create_func_repeat(Item* a, Item *b); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index f8488565b75..def465363fe 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1360,6 +1360,14 @@ String *Item_func_password::val_str(String *str) return str; } +char *Item_func_password::alloc(THD *thd, const char *password) +{ + char *buff= (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); + if (buff) + make_scrambled_password(buff, password); + return buff; +} + /* Item_func_old_password */ String *Item_func_old_password::val_str(String *str) @@ -1374,6 +1382,14 @@ String *Item_func_old_password::val_str(String *str) return str; } +char *Item_func_old_password::alloc(THD *thd, const char *password) +{ + char *buff= (char *) thd->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); + if (buff) + make_scrambled_password_323(buff, password); + return buff; +} + #define bin_to_ascii(c) ((c)>=38?((c)-38+'a'):(c)>=12?((c)-12+'A'):(c)+'.') diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 11f5a66b3d1..3e0239cf76a 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -270,6 +270,7 @@ public: String *val_str(String *str); void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH; } const char *func_name() const { return "password"; } + static char *alloc(THD *thd, const char *password); }; @@ -288,7 +289,7 @@ public: String *val_str(String *str); void fix_length_and_dec() { max_length= SCRAMBLED_PASSWORD_CHAR_LENGTH_323; } const char *func_name() const { return "old_password"; } - unsigned int size_of() { return sizeof(*this);} + static char *alloc(THD *thd, const char *password); }; diff --git a/sql/lex.h b/sql/lex.h index bb6e7a81ab4..f105fd4d9c8 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -284,6 +284,7 @@ static SYMBOL symbols[] = { { "NULL", SYM(NULL_SYM),0,0}, { "NUMERIC", SYM(NUMERIC_SYM),0,0}, { "OFFSET", SYM(OFFSET_SYM),0,0}, + { "OLD_PASSWORD", SYM(OLD_PASSWORD),0,0}, { "ON", SYM(ON),0,0}, { "OPEN", SYM(OPEN_SYM),0,0}, { "OPTIMIZE", SYM(OPTIMIZE),0,0}, @@ -577,7 +578,6 @@ static SYMBOL sql_functions[] = { { "NUMPOINTS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_numpoints)}, { "OCTET_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_length)}, { "OCT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_oct)}, - { "OLD_PASSWORD", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_old_password)}, { "ORD", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ord)}, { "OVERLAPS", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_overlaps)}, { "PERIOD_ADD", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_period_add)}, diff --git a/sql/password.c b/sql/password.c index be6514d89c6..bfdb453af01 100644 --- a/sql/password.c +++ b/sql/password.c @@ -446,22 +446,20 @@ make_scrambled_password(char *to, const char *password) Produce an obscure octet sequence from password and random string, recieved from the server. This sequence corresponds to the password, but password can not be easily restored from it. The sequence - is then sent to the server for validation. Trailing zero is stored in - the buf. + is then sent to the server for validation. Trailing zero is not stored + in the buf as it is not needed. This function is used by client to create authenticated reply to the server's greeting. SYNOPSIS scramble() buf OUT store scrambled string here. The buf must be at least - SHA1_HASH_SIZE+1 bytes long. + SHA1_HASH_SIZE bytes long. message IN random message, must be exactly SCRAMBLE_LENGTH long and NULL-terminated. password IN users' password - RETURN VALUE - end of scrambled string */ -char * +void scramble(char *to, const char *message, const char *password) { SHA1_CONTEXT sha1_context; @@ -483,8 +481,6 @@ scramble(char *to, const char *message, const char *password) /* xor allows 'from' and 'to' overlap: lets take advantage of it */ sha1_result(&sha1_context, (uint8 *) to); my_crypt(to, (const uint8 *) to, hash_stage1, SCRAMBLE_LENGTH); - to[SHA1_HASH_SIZE]= '\0'; - return to + SHA1_HASH_SIZE; } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index bbc6b74c3a9..f88799c2843 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -51,7 +51,7 @@ static byte* acl_entry_get_key(acl_entry *entry,uint *length, return (byte*) entry->key; } -#define ACL_KEY_LENGTH (sizeof(long)+NAME_LEN+17) +#define ACL_KEY_LENGTH (sizeof(long)+NAME_LEN+USERNAME_LENGTH+1) static DYNAMIC_ARRAY acl_hosts,acl_users,acl_dbs; static MEM_ROOT mem, memex; @@ -208,7 +208,8 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) DBUG_PRINT("info",("user table fields: %d, password length: %d", table->fields, table->field[2]->field_length)); - if (table->field[2]->field_length < 41 && !use_old_passwords) + if (table->field[2]->field_length < SCRAMBLED_PASSWORD_CHAR_LENGTH && + !use_old_passwords) { sql_print_error("mysql.user table is not updated to new password format; " "Disabling new password usage until " @@ -516,6 +517,7 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b) RETURN VALUE 0 success: thread data and mqh are updated 1 user not found or authentification failure + 2 user found, has long (4.1.1) salt, but passwd is in old (3.23) format. -1 user found, has short (3.23) salt, but passwd is in new (4.1.1) format. */ @@ -564,6 +566,9 @@ acl_getroot(THD *thd, USER_RESOURCES *mqh, else if (passwd_len == SCRAMBLE_LENGTH && user_i->salt_len == SCRAMBLE_LENGTH_323) res= -1; + else if (passwd_len == SCRAMBLE_LENGTH_323 && + user_i->salt_len == SCRAMBLE_LENGTH) + res= 2; /* linear search complete: */ break; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 384ec2bd4dd..a6d3121158c 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -195,11 +195,8 @@ end: RETURN VALUE 0 OK; thd->user, thd->master_access, thd->priv_user, thd->db and thd->db_access are updated; OK is sent to client; - 1 access denied or internal error; error is sent to client - Note, that this return semantics differs from check_connection, - which returns -1 if message was already sent. - -1 acl entry for this user contains old scramble, but passwd contains - new one, error is not sent to client + -1 access denied or handshake error; error is sent to client; + >0 error, not sent to client */ static int check_user(THD *thd, enum enum_server_command command, @@ -208,87 +205,129 @@ static int check_user(THD *thd, enum enum_server_command command, { DBUG_ENTER("check_user"); + if (passwd_len != 0 && + passwd_len != SCRAMBLE_LENGTH && + passwd_len != SCRAMBLE_LENGTH_323) + DBUG_RETURN(ER_HANDSHAKE_ERROR); + /* Why this is set here? - probably to reset current DB to 'no database selected' in case of 'change user' failure. */ thd->db= 0; thd->db_length= 0; - + + char buff[NAME_LEN + 1]; /* to conditionally save db */ + USER_RESOURCES ur; int res= acl_getroot(thd, &ur, passwd, passwd_len, protocol_version == 9 || !(thd->client_capabilities & CLIENT_LONG_PASSWORD)); - if (res == 0 && !(thd->master_access & NO_ACCESS)) // authentification is OK + if (res == -1) { - DBUG_PRINT("info", - ("Capabilities: %d packet_length: %ld Host: '%s' " - "Login user: '%s' Priv_user: '%s' Using password: %s " - "Access: %u db: '%s'", - thd->client_capabilities, thd->max_client_packet_length, - thd->host_or_ip, thd->user, thd->priv_user, - passwd_len ? "yes": "no", - thd->master_access, thd->db ? thd->db : "*none*")); - - if (check_count) + /* + This happens when client (new) sends password scrambled with + scramble(), but database holds old value (scrambled with + scramble_323()). Here we please client to send scrambled_password + in old format. + */ + /* save db because network buffer is to hold new packet */ + if (db) { - VOID(pthread_mutex_lock(&LOCK_thread_count)); - bool count_ok= thread_count < max_connections + delayed_insert_threads || - thd->master_access & SUPER_ACL; - VOID(pthread_mutex_unlock(&LOCK_thread_count)); - if (!count_ok) - { // too many connections - send_error(thd, ER_CON_COUNT_ERROR); - DBUG_RETURN(1); - } + strmake(buff, db, NAME_LEN); + db= buff; } - - /* Why logging is performed before all checks've passed? */ - mysql_log.write(thd,command, - (thd->priv_user == thd->user ? - (char*) "%s@%s on %s" : - (char*) "%s@%s as anonymous on %s"), - thd->user, thd->host_or_ip, - db ? db : (char*) ""); - - /* Why is it set here? */ - thd->db_access=0; - - /* Don't allow user to connect if he has done too many queries */ - if ((ur.questions || ur.updates || ur.connections) && - get_or_create_user_conn(thd,thd->user,thd->host_or_ip,&ur)) - DBUG_RETURN(1); - if (thd->user_connect && thd->user_connect->user_resources.connections && - check_for_max_user_connections(thd, thd->user_connect)) - DBUG_RETURN(1); - - /* Change database if necessary: OK or FAIL is sent in mysql_change_db */ - if (db && db[0]) + NET *net= &thd->net; + if (my_net_write(net, thd->scramble_323, SCRAMBLE_LENGTH_323 + 1) || + net_flush(net) || + my_net_read(net) != SCRAMBLE_LENGTH_323 + 1) // We have to read very + { // specific packet size + inc_host_errors(&thd->remote.sin_addr); + DBUG_RETURN(ER_HANDSHAKE_ERROR); + } + /* Final attempt to check the user based on reply */ + /* So as passwd is short, errcode is always >= 0 */ + res= acl_getroot(thd, &ur, (char *) net->read_pos, SCRAMBLE_LENGTH_323, + false); + } + /* here res is always >= 0 */ + if (res == 0) + { + if (!(thd->master_access & NO_ACCESS)) // authentification is OK { - if (mysql_change_db(thd, db)) + DBUG_PRINT("info", + ("Capabilities: %d packet_length: %ld Host: '%s' " + "Login user: '%s' Priv_user: '%s' Using password: %s " + "Access: %u db: '%s'", + thd->client_capabilities, thd->max_client_packet_length, + thd->host_or_ip, thd->user, thd->priv_user, + passwd_len ? "yes": "no", + thd->master_access, thd->db ? thd->db : "*none*")); + + if (check_count) { - if (thd->user_connect) - decrease_user_connections(thd->user_connect); - DBUG_RETURN(1); + VOID(pthread_mutex_lock(&LOCK_thread_count)); + bool count_ok= thread_count < max_connections + delayed_insert_threads + || thd->master_access & SUPER_ACL; + VOID(pthread_mutex_unlock(&LOCK_thread_count)); + if (!count_ok) + { // too many connections + send_error(thd, ER_CON_COUNT_ERROR); + DBUG_RETURN(-1); + } } + + /* Why logging is performed before all checks've passed? */ + mysql_log.write(thd,command, + (thd->priv_user == thd->user ? + (char*) "%s@%s on %s" : + (char*) "%s@%s as anonymous on %s"), + thd->user, thd->host_or_ip, + db ? db : (char*) ""); + + /* Why is it set here? */ + thd->db_access=0; + + /* Don't allow user to connect if he has done too many queries */ + if ((ur.questions || ur.updates || ur.connections) && + get_or_create_user_conn(thd,thd->user,thd->host_or_ip,&ur)) + DBUG_RETURN(1); + if (thd->user_connect && thd->user_connect->user_resources.connections && + check_for_max_user_connections(thd, thd->user_connect)) + DBUG_RETURN(1); + + /* Change database if necessary: OK or FAIL is sent in mysql_change_db */ + if (db && db[0]) + { + if (mysql_change_db(thd, db)) + { + if (thd->user_connect) + decrease_user_connections(thd->user_connect); + DBUG_RETURN(-1); + } + } + else + send_ok(thd); + thd->password= test(passwd_len); // remember for error messages + /* Ready to handle queries */ + DBUG_RETURN(0); } - else - send_ok(thd); - thd->password= test(passwd_len); // remember for error messages - /* Ready to handle queries */ } - else if (res != -1) // authentication failure + else if (res == 2) // client gave short hash, server has long hash { - net_printf(thd, ER_ACCESS_DENIED_ERROR, - thd->user, - thd->host_or_ip, - passwd_len ? ER(ER_YES) : ER(ER_NO)); - mysql_log.write(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR), - thd->user, - thd->host_or_ip, - passwd_len ? ER(ER_YES) : ER(ER_NO)); + net_printf(thd, ER_NOT_SUPPORTED_AUTH_MODE); + mysql_log.write(thd,COM_CONNECT,ER(ER_NOT_SUPPORTED_AUTH_MODE)); + DBUG_RETURN(-1); } - DBUG_RETURN(res); + net_printf(thd, ER_ACCESS_DENIED_ERROR, + thd->user, + thd->host_or_ip, + passwd_len ? ER(ER_YES) : ER(ER_NO)); + mysql_log.write(thd, COM_CONNECT, ER(ER_ACCESS_DENIED_ERROR), + thd->user, + thd->host_or_ip, + passwd_len ? ER(ER_YES) : ER(ER_NO)); + DBUG_RETURN(-1); } /* @@ -491,60 +530,6 @@ static void reset_mqh(THD *thd, LEX_USER *lu, bool get_them= 0) } -/* - Perform check for scrambled password, re-request scrambled password - from client if necessary. See also help for check_user. - SYNOPSIS - authenticate() - RETURN VALUE - 0 success, OK sent to client - -1 error, sent to client - > 0 error, not sent to client -*/ - -static -int -authenticate(THD *thd, enum enum_server_command command, - const char *passwd, uint passwd_len, const char *db, - bool check_count) -{ - if (passwd_len != 0 && - passwd_len != SCRAMBLE_LENGTH && - passwd_len != SCRAMBLE_LENGTH_323) - return 1; - int res= check_user(thd, COM_CONNECT, passwd, passwd_len, db, check_count); - if (res < 0) - { - /* - This happens when client (new) sends password scrambled with - scramble(), but database holds old value (scrambled with - scramble_323()). Here we please client to send scrambled_password - in old format. - */ - char buff[NAME_LEN + 1]; - /* save db because network buffer is to hold new packet */ - if (db) - { - strmake(buff, db, NAME_LEN); - db= buff; - } - NET *net= &thd->net; - if (my_net_write(net, thd->scramble_323, SCRAMBLE_LENGTH_323 + 1) || - net_flush(net) || - my_net_read(net) != SCRAMBLE_LENGTH_323 + 1) // We have to read very - { // specific packet size - inc_host_errors(&thd->remote.sin_addr); - return ER_HANDSHAKE_ERROR; - } - /* Final attempt to check the user based on reply */ - /* So as passwd is short, errcode is always sent to user and res >= 0 */ - res= check_user(thd, COM_CONNECT, (char *) net->read_pos, - SCRAMBLE_LENGTH_323, db, check_count); - } - return res > 0 ? -1 : 0; -} - - /* Perform handshake, authorize client and update thd ACL variables. SYNOPSIS @@ -643,7 +628,7 @@ check_connection(THD *thd) /* Old clients does not understand long scrambles, but can ignore packet - tail: that's why first part of scramble is placed here, and second + tail: that's why first part of the scramble is placed here, and second part at the end of packet. */ end= strmake(end, thd->scramble_323, SCRAMBLE_LENGTH_323) + 1; @@ -760,17 +745,23 @@ check_connection(THD *thd) char *user= end; char *passwd= strend(user)+1; - uint passwd_len= strlen(passwd); - - char *db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? - passwd+passwd_len+1 : 0; + char *db= passwd; + /* + Old clients send null-terminated string as password; new clients send + the size (1 byte) + string (not null-terminated). Hence in case of empty + password both send '\0'. + */ + uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? + *passwd++ : strlen(passwd); + db= thd->client_capabilities & CLIENT_CONNECT_WITH_DB ? + db + passwd_len + 1 : 0; if (thd->user) x_free(thd->user); thd->user= my_strdup(user, MYF(0)); if (!thd->user) return(ER_OUT_OF_RESOURCES); - return authenticate(thd, COM_CONNECT, passwd, passwd_len, db, true); + return check_user(thd, COM_CONNECT, passwd, passwd_len, db, true); } @@ -1137,8 +1128,15 @@ bool dispatch_command(enum enum_server_command command, THD *thd, statistic_increment(com_other, &LOCK_status); char *user= (char*) packet; char *passwd= strend(user)+1; - uint passwd_len= strlen(passwd); - char *db= passwd + passwd_len + 1; + /* + Old clients send null-terminated string ('\0' for empty string) for + password. New clients send the size (1 byte) + string (not null + terminated, so also '\0' for empty string). + */ + char *db= passwd; + uint passwd_len= thd->client_capabilities & CLIENT_SECURE_CONNECTION ? + *passwd++ : strlen(passwd); + db+= passwd_len + 1; /* Small check for incomming packet */ if ((uint) ((uchar*) db - net->read_pos) > packet_length) @@ -1163,7 +1161,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, break; } - int res= authenticate(thd, COM_CHANGE_USER, passwd, passwd_len, db, false); + int res= check_user(thd, COM_CHANGE_USER, passwd, passwd_len, db, false); if (res) { diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c8c9eb97a6a..ddf4b71e891 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -493,6 +493,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token MULTIPOINT %token MULTIPOLYGON %token NOW_SYM +%token OLD_PASSWORD %token PASSWORD %token POINTFROMTEXT %token POINT_SYM @@ -2516,9 +2517,11 @@ simple_expr: { $$= new Item_func_now($3); Lex->safe_to_cache_query=0;} | PASSWORD '(' expr ')' { - $$= use_old_passwords ? (Item *) new Item_func_old_password($3) : - (Item *) new Item_func_password($3); - } + $$= use_old_passwords ? (Item *) new Item_func_old_password($3) : + (Item *) new Item_func_password($3); + } + | OLD_PASSWORD '(' expr ')' + { $$= new Item_func_old_password($3); } | POINT_SYM '(' expr ',' expr ')' { $$= new Item_func_point($3,$5); } | POINTFROMTEXT '(' expr ')' @@ -4412,6 +4415,7 @@ keyword: | NO_SYM {} | NONE_SYM {} | OFFSET_SYM {} + | OLD_PASSWORD {} | OPEN_SYM {} | PACK_KEYS_SYM {} | PARTIAL {} @@ -4603,24 +4607,15 @@ text_or_password: TEXT_STRING { $$=$1.str;} | PASSWORD '(' TEXT_STRING ')' { - if (!$3.length) - $$=$3.str; - else if (use_old_passwords) - { - char *buff= (char *) - YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); - if (buff) - make_scrambled_password_323(buff, $3.str); - $$=buff; - } - else - { - char *buff= (char *) - YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH+1); - if (buff) - make_scrambled_password(buff, $3.str); - $$=buff; - } + $$= $3.length ? use_old_passwords ? + Item_func_old_password::alloc(YYTHD, $3.str) : + Item_func_password::alloc(YYTHD, $3.str) : + $3.str; + } + | OLD_PASSWORD '(' TEXT_STRING ')' + { + $$= $3.length ? Item_func_old_password::alloc(YYTHD, $3.str) : + $3.str; } ; From 78c3d9684ce2e83efc00878c3e901487bd5267bf Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 8 Jul 2003 02:36:14 +0400 Subject: [PATCH 003/282] Preliminary support for options --secure-auth, --old-passwords Support for option --old-protocol was removed. Some test performed. Tests for SSL and replication are pending. More strict following to specification for --old-passwords is in the TODO. include/mysql_com.h: support for 3.20 passwords removed from scramble_323 include/mysqld_error.h: added error code for --secure-auth mode libmysql/libmysql.c: removed support for 3.20 password and protocol version 9 mysql-test/r/connect.result: added check for new syntax of set password mysql-test/r/func_crypt.result: tests for two-argument of password() were removed. Instead added tests for cooperation of password() and old_passwords session/global variable, passwords() and spaces in argument string mysql-test/t/connect.test: added check for new syntax of set password mysql-test/t/func_crypt.test: tests for two-argument of password() were removed. Instead added tests for cooperation of password() and old_passwords session/global variable, passwords() and spaces in argument string sql-common/client.c: removed support for 3.20 servers and protocol version 9 sql/item_strfunc.h: fixed comment sql/mysql_priv.h: added declarartion for option opt_secure_auth sql/mysqld.cc: added option opt_secure_auth option old-password placed according to sort order sql/password.c: removed support for 3.20 clients and old scrambles sql/set_var.cc: added system variable 'secure_auth' added system/thread variable 'old_passwords' sql/set_var.h: sys_old_passwords needs to be exported because sys_old_passwords.after_update is used in sql_acl.cc sql/sql_acl.cc: support for 3.20 passwords removed now acl_init honors options works properly with options/variables --secure-auth and --old-passwords sql/sql_acl.h: support for 3.20 clients removed sql/sql_class.h: added system/thread variable old_passwords sql/sql_parse.cc: support for 3.20 clients removed now check_user takes into account option secure_auth sql/sql_yacc.yy: global variable use_old_passwords replaced with thread-specific variable old_passwords sql/share/czech/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/danish/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/dutch/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/english/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/estonian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/french/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/german/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/greek/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/hungarian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/italian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/japanese/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/korean/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/norwegian-ny/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/norwegian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/polish/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/portuguese/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/romanian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/russian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/serbian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/slovak/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/spanish/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/swedish/errmsg.txt: error message for --secure-auth added (as suggested by Paul) sql/share/ukrainian/errmsg.txt: error message for --secure-auth added (as suggested by Paul) --- include/mysql_com.h | 5 +- include/mysqld_error.h | 3 +- libmysql/libmysql.c | 6 +-- mysql-test/r/connect.result | 1 + mysql-test/r/func_crypt.result | 88 ++++++++++++++++++++++++++----- mysql-test/t/connect.test | 5 +- mysql-test/t/func_crypt.test | 34 ++++++++++-- sql-common/client.c | 6 +-- sql/item_strfunc.h | 2 +- sql/mysql_priv.h | 2 +- sql/mysqld.cc | 25 +++++---- sql/password.c | 55 ++++--------------- sql/set_var.cc | 6 +++ sql/set_var.h | 2 + sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + sql/sql_acl.cc | 82 ++++++++++++++++++---------- sql/sql_acl.h | 4 +- sql/sql_class.h | 1 + sql/sql_parse.cc | 32 ++++++++--- sql/sql_yacc.yy | 7 +-- 42 files changed, 264 insertions(+), 125 deletions(-) diff --git a/include/mysql_com.h b/include/mysql_com.h index 784a7782855..1f9d996c457 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -319,10 +319,9 @@ void create_random_string(char *to, uint length, struct rand_struct *rand_st); void hash_password(ulong *to, const char *password); void make_scrambled_password_323(char *to, const char *password); -char *scramble_323(char *to, const char *message, const char *password, - my_bool old_ver); +char *scramble_323(char *to, const char *message, const char *password); my_bool check_scramble_323(const char *, const char *message, - unsigned long *salt, my_bool old_ver); + unsigned long *salt); void get_salt_from_password_323(unsigned long *res, const char *password); void make_password_from_salt_323(char *to, const unsigned long *salt); diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 565c2812c50..341e0144ca3 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -286,4 +286,5 @@ #define ER_REVOKE_GRANTS 1267 #define ER_CANT_AGGREGATE_3COLLATIONS 1268 #define ER_CANT_AGGREGATE_NCOLLATIONS 1269 -#define ER_ERROR_MESSAGES 270 +#define ER_SERVER_IS_IN_SECURE_AUTH_MODE 1270 +#define ER_ERROR_MESSAGES 271 diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 8b83343df8f..1cf4880db24 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -626,8 +626,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, end+= SCRAMBLE_LENGTH; } else - end= scramble_323(end, mysql->scramble_323, passwd, - (my_bool) (mysql->protocol_version == 9)) + 1; + end= scramble_323(end, mysql->scramble_323, passwd); } else *end++= '\0'; // empty password @@ -651,8 +650,7 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, By sending this very specific reply server asks us to send scrambled password in old format. The reply contains scramble_323. */ - scramble_323(buff, mysql->scramble_323, passwd, - (my_bool) (mysql->protocol_version == 9)); + scramble_323(buff, mysql->scramble_323, passwd); if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) { net->last_errno= CR_SERVER_LOST; diff --git a/mysql-test/r/connect.result b/mysql-test/r/connect.result index 9c848c3434f..c0608af0de2 100644 --- a/mysql-test/r/connect.result +++ b/mysql-test/r/connect.result @@ -30,6 +30,7 @@ show tables; Tables_in_test update mysql.user set password=old_password("gambling2") where user="test"; flush privileges; +set password=old_password('gambling3'); show tables; Tables_in_mysql columns_priv diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result index 461ae1e7e09..bd4c6d41d39 100644 --- a/mysql-test/r/func_crypt.result +++ b/mysql-test/r/func_crypt.result @@ -1,15 +1,79 @@ select length(encrypt('foo', 'ff')) <> 0; length(encrypt('foo', 'ff')) <> 0 1 -select password("a",""), password("a",NULL), password("","a"), password(NULL,"a"); -password("a","") password("a",NULL) password("","a") password(NULL,"a") -*2517f7235d68d4ba2e5019c93420523101157a792c01 NULL NULL -select password("aaaaaaaaaaaaaaaa","a"), password("a","aaaaaaaaaaaaaaaa"); -password("aaaaaaaaaaaaaaaa","a") password("a","aaaaaaaaaaaaaaaa") -*2cd3b9a44e9a9994789a30f935c92f45a96c5472f381 *37c7c5c794ff144819f2531bf03c57772cd84e40db09 -select old_password('test'), length(password("1")), length(encrypt('test')), encrypt('test','aa'); -old_password('test') length(password("1")) length(encrypt('test')) encrypt('test','aa') -378b243e220ca493 45 13 aaqPiZY5xR5l. -select old_password(""), old_password(NULL), password(""), password(NULL); -old_password("") old_password(NULL) password("") password(NULL) - NULL NULL +select password('abc'); +password('abc') +*0d3ced9bec10a777aec23ccc353a8c08a633045e +select password(''); +password('') + +select old_password('abc'); +old_password('abc') +7cd2b5942be28759 +select old_password(''); +old_password('') + +select password('gabbagabbahey'); +password('gabbagabbahey') +*b0f99d2963660dd7e16b751ec9ee2f17b6a68fa6 +select old_password('idkfa'); +old_password('idkfa') +5c078dc54ca0fcca +select length(password('1')); +length(password('1')) +41 +select length(encrypt('test')); +length(encrypt('test')) +13 +select encrypt('test','aa'); +encrypt('test','aa') +aaqPiZY5xR5l. +select old_password(NULL); +old_password(NULL) +NULL +select password(NULL); +password(NULL) +NULL +set global old_passwords=on; +select password(''); +password('') + +select old_password(''); +old_password('') + +select password('idkfa'); +password('idkfa') +*b669c9dac3aa6f2254b03cdef8dfdd6b2d1054ba +select old_password('idkfa'); +old_password('idkfa') +5c078dc54ca0fcca +set old_passwords=on; +select password('idkfa'); +password('idkfa') +5c078dc54ca0fcca +select old_password('idkfa'); +old_password('idkfa') +5c078dc54ca0fcca +set global old_passwords=off; +select password('idkfa'); +password('idkfa') +5c078dc54ca0fcca +select old_password('idkfa'); +old_password('idkfa') +5c078dc54ca0fcca +set old_passwords=off; +select password('idkfa '); +password('idkfa ') +*2dc31d90647b4c1abc9231563d2236e96c9a2db2 +select password('idkfa'); +password('idkfa') +*b669c9dac3aa6f2254b03cdef8dfdd6b2d1054ba +select password(' idkfa'); +password(' idkfa') +*12b099e56bb7fe8d43c78fd834a9d1d11178d045 +select old_password('idkfa'); +old_password('idkfa') +5c078dc54ca0fcca +select old_password(' i d k f a '); +old_password(' i d k f a ') +5c078dc54ca0fcca diff --git a/mysql-test/t/connect.test b/mysql-test/t/connect.test index e6ccc52f0d4..7585ff0f608 100644 --- a/mysql-test/t/connect.test +++ b/mysql-test/t/connect.test @@ -48,8 +48,9 @@ flush privileges; #connect (con1,localhost,test,gambling2,""); #show tables; connect (con1,localhost,test,gambling2,mysql); +set password=old_password('gambling3'); show tables; -connect (con1,localhost,test,gambling2,test); +connect (con1,localhost,test,gambling3,test); show tables; # Re enable this one day if error handling on connect will take place @@ -63,7 +64,9 @@ show tables; #connect (con1,localhost,test,zorro,); #--error 1045 + # remove user 'test' so that other tests which may use 'test' # do not depend on this test. + delete from mysql.user where user="test"; flush privileges; diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test index c72356bda1a..c1c7090cab3 100644 --- a/mysql-test/t/func_crypt.test +++ b/mysql-test/t/func_crypt.test @@ -4,7 +4,33 @@ select length(encrypt('foo', 'ff')) <> 0; --replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l. # Test new and old password handling functions -select password("a",""), password("a",NULL), password("","a"), password(NULL,"a"); -select password("aaaaaaaaaaaaaaaa","a"), password("a","aaaaaaaaaaaaaaaa"); -select old_password('test'), length(password("1")), length(encrypt('test')), encrypt('test','aa'); -select old_password(""), old_password(NULL), password(""), password(NULL); +select password('abc'); +select password(''); +select old_password('abc'); +select old_password(''); +select password('gabbagabbahey'); +select old_password('idkfa'); +select length(password('1')); +select length(encrypt('test')); +select encrypt('test','aa'); +select old_password(NULL); +select password(NULL); +set global old_passwords=on; +select password(''); +select old_password(''); +select password('idkfa'); +select old_password('idkfa'); +set old_passwords=on; +select password('idkfa'); +select old_password('idkfa'); +set global old_passwords=off; +select password('idkfa'); +select old_password('idkfa'); + +# this test shows that new scrambles honor spaces in passwords: +set old_passwords=off; +select password('idkfa '); +select password('idkfa'); +select password(' idkfa'); +select old_password('idkfa'); +select old_password(' i d k f a '); diff --git a/sql-common/client.c b/sql-common/client.c index efb71021f8d..9a0b7eb3fe2 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1842,8 +1842,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, end+= SCRAMBLE_LENGTH; } else - end= scramble_323(end, mysql->scramble_323, passwd, - (my_bool) (mysql->protocol_version == 9)) + 1; + end= scramble_323(end, mysql->scramble_323, passwd) + 1; } else *end++= '\0'; /* empty password */ @@ -1880,8 +1879,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, By sending this very specific reply server asks us to send scrambled password in old format. The reply contains scramble_323. */ - scramble_323(buff, mysql->scramble_323, passwd, - (my_bool) (mysql->protocol_version == 9)); + scramble_323(buff, mysql->scramble_323, passwd); if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) { net->last_errno= CR_SERVER_LOST; diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 3e0239cf76a..96e264fd8d2 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -277,7 +277,7 @@ public: /* Item_func_old_password -- PASSWORD() implementation used in MySQL 3.21 - 4.0 compatibility mode. This item is created in sql_yacc.yy when - 'use_old_passwords' session variable is set, and to handle OLD_PASSWORD() + 'old_passwords' session variable is set, and to handle OLD_PASSWORD() function. */ diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 13ff168e553..f8bf197249b 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -748,7 +748,7 @@ extern my_bool opt_safe_show_db, opt_local_infile, lower_case_table_names; extern my_bool opt_slave_compressed_protocol, use_temp_pool; extern my_bool opt_readonly; extern my_bool opt_enable_named_pipe; -extern my_bool opt_old_passwords, use_old_passwords; +extern my_bool opt_secure_auth; extern char *shared_memory_base_name, *mysqld_unix_port; extern bool opt_enable_shared_memory; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 2677973ff0e..c5f875bfcc8 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -250,9 +250,10 @@ my_bool opt_local_infile, opt_external_locking, opt_slave_compressed_protocol; my_bool opt_safe_user_create = 0, opt_no_mix_types = 0; my_bool lower_case_table_names, opt_old_rpl_compat; my_bool opt_show_slave_auth_info, opt_sql_bin_update = 0; -my_bool opt_log_slave_updates= 0, opt_old_passwords=0, use_old_passwords=0; +my_bool opt_log_slave_updates= 0; my_bool opt_console= 0, opt_bdb, opt_innodb, opt_isam; my_bool opt_readonly, use_temp_pool, relay_log_purge; +my_bool opt_secure_auth= 0; volatile bool mqh_used = 0; uint mysqld_port, test_flags, select_errors, dropping_tables, ha_open_options; @@ -3452,7 +3453,8 @@ enum options OPT_EXPIRE_LOGS_DAYS, OPT_DEFAULT_WEEK_FORMAT, OPT_GROUP_CONCAT_MAX_LEN, - OPT_DEFAULT_COLLATION + OPT_DEFAULT_COLLATION, + OPT_SECURE_AUTH }; @@ -3753,9 +3755,10 @@ Does nothing yet.", (gptr*) &opt_no_mix_types, (gptr*) &opt_no_mix_types, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"old-protocol", 'o', "Use the old (3.20) protocol client/server protocol.", - (gptr*) &protocol_version, (gptr*) &protocol_version, 0, GET_UINT, NO_ARG, - PROTOCOL_VERSION, 0, 0, 0, 0, 0}, + {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for 4.0 and older clients).", + (gptr*) &global_system_variables.old_passwords, + (gptr*) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG, + 0, 0, 0, 0, 0, 0}, {"old-rpl-compat", OPT_OLD_RPL_COMPAT, "Use old LOAD DATA format in the binary log (don't save data in file).", (gptr*) &opt_old_rpl_compat, (gptr*) &opt_old_rpl_compat, 0, GET_BOOL, @@ -3824,8 +3827,6 @@ relay logs.", GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for 4.0 and older clients).", - (gptr*) &opt_old_passwords, (gptr*) &opt_old_passwords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef TO_BE_DELETED {"safe-show-database", OPT_SAFE_SHOW_DB, "Deprecated option; One should use GRANT SHOW DATABASES instead...", @@ -3835,6 +3836,9 @@ relay logs.", "Don't allow new user creation by the user who has no write privileges to the mysql.user table.", (gptr*) &opt_safe_user_create, (gptr*) &opt_safe_user_create, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"secure-auth", OPT_SECURE_AUTH, "Disallow authentication for accounts that have old (pre-4.1) passwords.", + (gptr*) &opt_secure_auth, (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, + my_bool(0), 0, 0, 0, 0, 0}, {"server-id", OPT_SERVER_ID, "Uniquely identifies the server instance in the community of replication partners.", (gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, @@ -4604,7 +4608,8 @@ static void mysql_init_variables(void) opt_log= opt_update_log= opt_bin_log= opt_slow_log= 0; opt_disable_networking= opt_skip_show_db=0; opt_logname= opt_update_logname= opt_binlog_index_name= opt_slow_logname=0; - opt_bootstrap= opt_myisam_log= use_old_passwords= 0; + opt_secure_auth= 0; + opt_bootstrap= opt_myisam_log= 0; mqh_used= 0; segfaulted= kill_in_progress= 0; cleanup_done= 0; @@ -4704,6 +4709,7 @@ static void mysql_init_variables(void) max_system_variables.select_limit= (ulonglong) HA_POS_ERROR; global_system_variables.max_join_size= (ulonglong) HA_POS_ERROR; max_system_variables.max_join_size= (ulonglong) HA_POS_ERROR; + global_system_variables.old_passwords= 0; /* Variables that depends on compile options */ #ifndef DBUG_OFF @@ -4825,9 +4831,6 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), case 'L': strmake(language, argument, sizeof(language)-1); break; - case 'o': - protocol_version=PROTOCOL_VERSION-1; - break; #ifdef HAVE_REPLICATION case OPT_SLAVE_SKIP_ERRORS: init_slave_skip_errors(argument); diff --git a/sql/password.c b/sql/password.c index bfdb453af01..2e9139c12aa 100644 --- a/sql/password.c +++ b/sql/password.c @@ -88,24 +88,6 @@ void randominit(struct rand_struct *rand_st, ulong seed1, ulong seed2) } -/* - Old (MySQL 3.20) random generation structure initialization - XXX: is to be deleted very soon! - SYNOPSIS - old_randominit() - rand_st OUT Structure to initialize - seed1 IN First initialization parameter -*/ - -static void old_randominit(struct rand_struct *rand_st, ulong seed1) -{ /* For mysql 3.20.# */ - rand_st->max_value= 0x01FFFFFFL; - rand_st->max_value_dbl=(double) rand_st->max_value; - seed1%=rand_st->max_value; - rand_st->seed1=seed1 ; rand_st->seed2=seed1/2; -} - - /* Generate random number. SYNOPSIS @@ -178,13 +160,11 @@ void make_scrambled_password_323(char *to, const char *password) message IN Message to scramble. Message must be exactly SRAMBLE_LENGTH_323 long and NULL terminated. password IN Password to use while scrambling - old_ver IN Force old version random number generator RETURN End of scrambled string */ -char *scramble_323(char *to, const char *message, const char *password, - my_bool old_ver) +char *scramble_323(char *to, const char *message, const char *password) { struct rand_struct rand_st; ulong hash_pass[2], hash_message[2]; @@ -194,21 +174,15 @@ char *scramble_323(char *to, const char *message, const char *password, char *to_start=to; hash_password(hash_pass,password); hash_password(hash_message, message); - if (old_ver) - old_randominit(&rand_st,hash_pass[0] ^ hash_message[0]); - else - randominit(&rand_st,hash_pass[0] ^ hash_message[0], - hash_pass[1] ^ hash_message[1]); + randominit(&rand_st,hash_pass[0] ^ hash_message[0], + hash_pass[1] ^ hash_message[1]); while (*message++) *to++= (char) (floor(my_rnd(&rand_st)*31)+64); - if (!old_ver) - { /* Make it harder to break */ - char extra=(char) (floor(my_rnd(&rand_st)*31)); - while (to_start != to) - *(to_start++)^=extra; - } + char extra=(char) (floor(my_rnd(&rand_st)*31)); + while (to_start != to) + *(to_start++)^=extra; } - *to=0; + *to= 0; return to; } @@ -223,7 +197,6 @@ char *scramble_323(char *to, const char *message, const char *password, be exactly SCRAMBLED_LENGTH_323 bytes long and NULL-terminated. hash_pass IN password which should be used for scrambling - old_ver IN force old (3.20) version random number generator RETURN VALUE 0 - password correct !0 - password invalid @@ -231,7 +204,7 @@ char *scramble_323(char *to, const char *message, const char *password, my_bool check_scramble_323(const char *scrambled, const char *message, - ulong *hash_pass, my_bool old_ver) + ulong *hash_pass) { struct rand_struct rand_st; ulong hash_message[2]; @@ -243,18 +216,12 @@ check_scramble_323(const char *scrambled, const char *message, return 1; /* Wrong password */ hash_password(hash_message,message); - if (old_ver) - old_randominit(&rand_st,hash_pass[0] ^ hash_message[0]); - else - randominit(&rand_st,hash_pass[0] ^ hash_message[0], - hash_pass[1] ^ hash_message[1]); + randominit(&rand_st,hash_pass[0] ^ hash_message[0], + hash_pass[1] ^ hash_message[1]); to=buff; for (pos=scrambled ; *pos ; pos++) *to++=(char) (floor(my_rnd(&rand_st)*31)+64); - if (old_ver) - extra=0; - else - extra=(char) (floor(my_rnd(&rand_st)*31)); + extra=(char) (floor(my_rnd(&rand_st)*31)); to=buff; while (*scrambled) { diff --git a/sql/set_var.cc b/sql/set_var.cc index a281fac530a..a4ecf24d09f 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -210,6 +210,7 @@ sys_var_thd_ulong sys_net_retry_count("net_retry_count", &SV::net_retry_count, fix_net_retry_count); sys_var_thd_bool sys_new_mode("new", &SV::new_mode); +sys_var_thd_bool sys_old_passwords("old_passwords", &SV::old_passwords); sys_var_thd_ulong sys_preload_buff_size("preload_buffer_size", &SV::preload_buff_size); sys_var_thd_ulong sys_read_buff_size("read_buffer_size", @@ -236,6 +237,7 @@ sys_var_thd_enum sys_query_cache_type("query_cache_type", &SV::query_cache_type, &query_cache_type_typelib); #endif /* HAVE_QUERY_CACHE */ +sys_var_bool_ptr sys_secure_auth("secure_auth", &opt_secure_auth); sys_var_long_ptr sys_server_id("server_id",&server_id); sys_var_bool_ptr sys_slave_compressed_protocol("slave_compressed_protocol", &opt_slave_compressed_protocol); @@ -425,6 +427,7 @@ sys_var *sys_variables[]= &sys_net_wait_timeout, &sys_net_write_timeout, &sys_new_mode, + &sys_old_passwords, &sys_preload_buff_size, &sys_pseudo_thread_id, &sys_query_cache_size, @@ -443,6 +446,7 @@ sys_var *sys_variables[]= #endif &sys_rpl_recovery_rank, &sys_safe_updates, + &sys_secure_auth, &sys_select_limit, &sys_server_id, #ifdef HAVE_REPLICATION @@ -600,6 +604,7 @@ struct show_var_st init_vars[]= { {sys_net_retry_count.name, (char*) &sys_net_retry_count, SHOW_SYS}, {sys_net_write_timeout.name,(char*) &sys_net_write_timeout, SHOW_SYS}, {sys_new_mode.name, (char*) &sys_new_mode, SHOW_SYS}, + {sys_old_passwords.name, (char*) &sys_old_passwords, SHOW_SYS}, {"open_files_limit", (char*) &open_files_limit, SHOW_LONG}, {"pid_file", (char*) pidfile_name, SHOW_CHAR}, {"log_error", (char*) log_error_file, SHOW_CHAR}, @@ -620,6 +625,7 @@ struct show_var_st init_vars[]= { SHOW_SYS}, {sys_query_cache_size.name, (char*) &sys_query_cache_size, SHOW_SYS}, {sys_query_cache_type.name, (char*) &sys_query_cache_type, SHOW_SYS}, + {"secure_auth", (char*) &sys_secure_auth, SHOW_SYS}, #endif /* HAVE_QUERY_CACHE */ #ifdef HAVE_SMEM {"shared_memory", (char*) &opt_enable_shared_memory, SHOW_MY_BOOL}, diff --git a/sql/set_var.h b/sql/set_var.h index 5a0fbd21809..0622e504499 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -652,3 +652,5 @@ ulong fix_sql_mode(ulong sql_mode); extern sys_var_str sys_charset_system; CHARSET_INFO *get_old_charset_by_name(const char *old_name); + +extern sys_var_thd_bool sys_old_passwords; diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 641b1384e9a..4f1836ef80a 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -275,3 +275,4 @@ v/* "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 574d26b7c1c..138c8c59a39 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -269,3 +269,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index c6c975cb141..f7a79dfa738 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -277,3 +277,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index f39c415fa55..c57527e2578 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -271,3 +271,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index de22d6fd111..e6ade1c7e3d 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -271,3 +271,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index 6c1187cd0e4..7ffd834fbcf 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -266,3 +266,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index 78d53034a71..2c6343eeeea 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -275,3 +275,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index 347370f1ac8..228834f7937 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -266,3 +266,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 313275b3cb6..620234e2321 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -268,3 +268,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 8af7e3ba9f7..8091d3185ba 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -266,3 +266,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 417a03978fb..962505423b1 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -268,3 +268,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index 22395d0fb6a..aa0439fcd32 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -266,3 +266,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index de6db62cdce..21dfad648b9 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -268,3 +268,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index 28db8caa8bc..e1d7501bca4 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -268,3 +268,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index fdf856c7e56..eaa2395b675 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -270,3 +270,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index 397784dc7dd..89aded8afce 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -266,3 +266,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 8f1cdb7b259..e76fd43e841 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -270,3 +270,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index ec41a6acb34..23d20c1b8fe 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -268,3 +268,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"óÅÒ×ÅÒ ÚÁÐÕÝÅÎ × ÒÅÖÉÍÅ --secure-auth (ÂÅÚÏÐÁÓÎÏÊ Á×ÔÏÒÉÚÁÃÉÉ), ÎÏ ÄÌÑ ÐÏÌØÚÏ×ÁÔÅÌÑ '%s@%s' ÐÁÒÏÌØ ÓÏÈÒÁÎ£Î × ÓÔÁÒÏÍ ÆÏÒÍÁÔÅ; ÎÅÏÂÈÏÄÉÍÏ ÏÂÎÏ×ÉÔØ ÆÏÒÍÁÔ ÐÁÒÏÌÑ" diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index 77d35be2fc9..e0ba1413f5e 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -262,3 +262,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 33cabdfc752..bc8949127fd 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -274,3 +274,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 35e26f35ff7..9a6dcd90a4d 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -267,3 +267,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 9cdcb20db35..3538ba3c47e 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -266,3 +266,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 5a614714de2..9bc07241856 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -271,3 +271,4 @@ "Can't revoke all privileges, grant for one or more of the requested users" "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", +"Server is running in --secure-auth mode, but '%s@%s' has a password in the old format; please change the password to the new format" diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index f88799c2843..ee544335a99 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -87,16 +87,33 @@ set_user_salt(ACL_USER *acl_user, const char *password, uint password_len) get_salt_from_password(acl_user->salt, password); acl_user->salt_len= SCRAMBLE_LENGTH; } - else if (password_len == SCRAMBLED_PASSWORD_CHAR_LENGTH_323 - || password_len == 8 && protocol_version == 9) + else if (password_len == SCRAMBLED_PASSWORD_CHAR_LENGTH_323) { get_salt_from_password_323((ulong *) acl_user->salt, password); - acl_user->salt_len= password_len/2; + acl_user->salt_len= SCRAMBLE_LENGTH_323; } else acl_user->salt_len= 0; } +/* + This after_update function is used when user.password is less than + SCRAMBLE_LENGTH bytes. +*/ + +static void restrict_update_of_old_passwords_var(THD *thd, + enum_var_type var_type) +{ + if (var_type == OPT_GLOBAL) + { + pthread_mutex_lock(&LOCK_global_system_variables); + global_system_variables.old_passwords= 1; + pthread_mutex_unlock(&LOCK_global_system_variables); + } + else + thd->variables.old_passwords= 1; +} + /* Read grant privileges from the privilege tables in the 'mysql' database. @@ -139,8 +156,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) if (!(thd=new THD)) DBUG_RETURN(1); /* purecov: inspected */ thd->store_globals(); - /* Use passwords according to command line option */ - use_old_passwords= opt_old_passwords; acl_cache->clear(1); // Clear locked hostname cache thd->db= my_strdup("mysql",MYF(0)); @@ -197,24 +212,43 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) init_read_record(&read_record_info,thd,table=tables[1].table,NULL,1,0); VOID(my_init_dynamic_array(&acl_users,sizeof(ACL_USER),50,100)); - if (table->field[2]->field_length == 8 && - protocol_version == PROTOCOL_VERSION) + if (table->field[2]->field_length < SCRAMBLED_PASSWORD_CHAR_LENGTH_323) { - sql_print_error("Old 'user' table. " - "(Check README or the Reference manual). " - "Continuing --old-protocol"); /* purecov: tested */ - protocol_version=9; /* purecov: tested */ + sql_print_error("Fatal error: mysql.user table is damaged or in " + "unsupported 3.20 format."); + goto end; } DBUG_PRINT("info",("user table fields: %d, password length: %d", table->fields, table->field[2]->field_length)); - if (table->field[2]->field_length < SCRAMBLED_PASSWORD_CHAR_LENGTH && - !use_old_passwords) + + pthread_mutex_lock(&LOCK_global_system_variables); + if (table->field[2]->field_length < SCRAMBLED_PASSWORD_CHAR_LENGTH) { - sql_print_error("mysql.user table is not updated to new password format; " - "Disabling new password usage until " - "mysql_fix_privilege_tables is run"); - use_old_passwords= 1; + if (opt_secure_auth) + { + pthread_mutex_unlock(&LOCK_global_system_variables); + sql_print_error("Fatal error: mysql.user table is in old format, " + "but server started with --secure-auth option."); + goto end; + } + sys_old_passwords.after_update= restrict_update_of_old_passwords_var; + if (global_system_variables.old_passwords) + pthread_mutex_unlock(&LOCK_global_system_variables); + else + { + global_system_variables.old_passwords= 1; + pthread_mutex_unlock(&LOCK_global_system_variables); + sql_print_error("mysql.user table is not updated to new password format; " + "Disabling new password usage until " + "mysql_fix_privilege_tables is run"); + } + thd->variables.old_passwords= 1; + } + else + { + sys_old_passwords.after_update= 0; + pthread_mutex_unlock(&LOCK_global_system_variables); } allow_all_hosts=0; @@ -229,12 +263,6 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) if (user.salt_len == 0 && password_len != 0) { switch (password_len) { - case 8: /* 3.20: to be removed */ - sql_print_error("Found old style password for user '%s'. " - "Ignoring user. (You may want to restart mysqld " - "using --old-protocol) ", - user.user ? user.user : ""); - break; case 45: /* 4.1: to be removed */ sql_print_error("Found 4.1 style password for user '%s'. " "Ignoring user. " @@ -513,7 +541,6 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b) original random string, passwd_len IN length of passwd, must be one of 0, 8, SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH - old_version IN if old (3.20) protocol is used RETURN VALUE 0 success: thread data and mqh are updated 1 user not found or authentification failure @@ -521,9 +548,8 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b) -1 user found, has short (3.23) salt, but passwd is in new (4.1.1) format. */ -int -acl_getroot(THD *thd, USER_RESOURCES *mqh, - const char *passwd, uint passwd_len, bool old_version) +int acl_getroot(THD *thd, USER_RESOURCES *mqh, + const char *passwd, uint passwd_len) { DBUG_ENTER("acl_getroot"); @@ -557,7 +583,7 @@ acl_getroot(THD *thd, USER_RESOURCES *mqh, user_i->salt_len == SCRAMBLE_LENGTH && check_scramble(passwd, thd->scramble, user_i->salt) == 0 || check_scramble_323(passwd, thd->scramble_323, - (ulong *) user_i->salt, old_version) == 0) + (ulong *) user_i->salt) == 0) { acl_user= user_i; res= 0; diff --git a/sql/sql_acl.h b/sql/sql_acl.h index 3370797820a..b4ee1a9b15f 100644 --- a/sql/sql_acl.h +++ b/sql/sql_acl.h @@ -135,8 +135,8 @@ void acl_reload(THD *thd); void acl_free(bool end=0); ulong acl_get(const char *host, const char *ip, const char *bin_ip, const char *user, const char *db); -int acl_getroot(THD *thd, USER_RESOURCES *mqh, - const char *passwd, uint passwd_len, bool old_ver); +int acl_getroot(THD *thd, USER_RESOURCES *mqh, const char *passwd, + uint passwd_len); bool acl_check_host(const char *host, const char *ip); bool check_change_password(THD *thd, const char *host, const char *user); bool change_password(THD *thd, const char *host, const char *user, diff --git a/sql/sql_class.h b/sql/sql_class.h index d962cc8086e..5e46f44634b 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -386,6 +386,7 @@ struct system_variables my_bool log_warnings; my_bool low_priority_updates; my_bool new_mode; + my_bool old_passwords; CHARSET_INFO *character_set_server; CHARSET_INFO *character_set_database; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index a6d3121158c..4b7486c7b4f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -204,7 +204,22 @@ static int check_user(THD *thd, enum enum_server_command command, bool check_count) { DBUG_ENTER("check_user"); - + + my_bool opt_secure_auth_local; + pthread_mutex_lock(&LOCK_global_system_variables); + opt_secure_auth_local= opt_secure_auth; + pthread_mutex_unlock(&LOCK_global_system_variables); + + /* + If the server is running in secure auth mode, short scrambles are + forbidden. + */ + if (opt_secure_auth_local && passwd_len == SCRAMBLE_LENGTH_323) + { + net_printf(thd, ER_NOT_SUPPORTED_AUTH_MODE); + mysql_log.write(thd, COM_CONNECT, ER(ER_NOT_SUPPORTED_AUTH_MODE)); + DBUG_RETURN(-1); + } if (passwd_len != 0 && passwd_len != SCRAMBLE_LENGTH && passwd_len != SCRAMBLE_LENGTH_323) @@ -220,9 +235,7 @@ static int check_user(THD *thd, enum enum_server_command command, char buff[NAME_LEN + 1]; /* to conditionally save db */ USER_RESOURCES ur; - int res= acl_getroot(thd, &ur, passwd, passwd_len, - protocol_version == 9 || - !(thd->client_capabilities & CLIENT_LONG_PASSWORD)); + int res= acl_getroot(thd, &ur, passwd, passwd_len); if (res == -1) { /* @@ -231,6 +244,14 @@ static int check_user(THD *thd, enum enum_server_command command, scramble_323()). Here we please client to send scrambled_password in old format. */ + if (opt_secure_auth_local) + { + net_printf(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE, + thd->user, thd->host_or_ip); + mysql_log.write(thd, COM_CONNECT, ER(ER_SERVER_IS_IN_SECURE_AUTH_MODE), + thd->user, thd->host_or_ip); + DBUG_RETURN(-1); + } /* save db because network buffer is to hold new packet */ if (db) { @@ -247,8 +268,7 @@ static int check_user(THD *thd, enum enum_server_command command, } /* Final attempt to check the user based on reply */ /* So as passwd is short, errcode is always >= 0 */ - res= acl_getroot(thd, &ur, (char *) net->read_pos, SCRAMBLE_LENGTH_323, - false); + res= acl_getroot(thd, &ur, (char *) net->read_pos, SCRAMBLE_LENGTH_323); } /* here res is always >= 0 */ if (res == 0) diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index ddf4b71e891..e283991b496 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2517,7 +2517,8 @@ simple_expr: { $$= new Item_func_now($3); Lex->safe_to_cache_query=0;} | PASSWORD '(' expr ')' { - $$= use_old_passwords ? (Item *) new Item_func_old_password($3) : + $$= YYTHD->variables.old_passwords ? + (Item *) new Item_func_old_password($3) : (Item *) new Item_func_password($3); } | OLD_PASSWORD '(' expr ')' @@ -4607,7 +4608,7 @@ text_or_password: TEXT_STRING { $$=$1.str;} | PASSWORD '(' TEXT_STRING ')' { - $$= $3.length ? use_old_passwords ? + $$= $3.length ? YYTHD->variables.old_passwords ? Item_func_old_password::alloc(YYTHD, $3.str) : Item_func_password::alloc(YYTHD, $3.str) : $3.str; @@ -4923,7 +4924,7 @@ grant_user: $$=$1; $1->password=$4; if ($4.length) { - if (use_old_passwords) + if (YYTHD->variables.old_passwords) { char *buff= (char *) YYTHD->alloc(SCRAMBLED_PASSWORD_CHAR_LENGTH_323+1); From cae6ffdceec8d65b3320edc36b0b5c8ef5fbcfbe Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jul 2003 15:52:51 +0300 Subject: [PATCH 004/282] Fix for a bug #807 --- sql/item_cmpfunc.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 5d47fa302f3..b7b97dc80f9 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -295,6 +295,7 @@ void Item_func_interval::fix_length_and_dec() used_tables_cache|= item->used_tables(); not_null_tables_cache&= item->not_null_tables(); with_sum_func= with_sum_func || item->with_sum_func; + const_item_cache&=item->const_item(); } From 628b5c39f8f05c36d5bdabc092e66723853e2070 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jul 2003 22:33:26 +0300 Subject: [PATCH 005/282] Test case for bug #807 --- mysql-test/r/group_by.result | 11 +++++++++++ mysql-test/t/group_by.test | 2 ++ 2 files changed, 13 insertions(+) diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 67e6bec09f6..f89cb8a6792 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -585,4 +585,15 @@ select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(q id sqty cqty 1 5 2 2 9 2 +select count(*), case interval(qty,2,3,4,5,6,7,8) when -1 then NULL when 0 then "zero" when 1 then "one" when 2 then "two" end as category from t1 group by category; +count(*) category +2 NULL +1 one +1 two +select count(*), interval(qty,2,3,4,5,6,7,8) as category from t1 group by category; +count(*) category +1 1 +1 2 +1 3 +1 4 drop table t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 67f4eb580a6..df99bc2a9dc 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -420,4 +420,6 @@ select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(q select id, sum(qty) as sqty from t1 group by id having sqty>2 and count(qty)>1; select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sqty>2 and cqty>1; select id, sum(qty) as sqty, count(qty) as cqty from t1 group by id having sum(qty)>2 and count(qty)>1; +select count(*), case interval(qty,2,3,4,5,6,7,8) when -1 then NULL when 0 then "zero" when 1 then "one" when 2 then "two" end as category from t1 group by category; +select count(*), interval(qty,2,3,4,5,6,7,8) as category from t1 group by category; drop table t1; From 30ced7f7f61aa25b486ab2134b1fa81310647bc6 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jul 2003 18:25:54 +0400 Subject: [PATCH 006/282] Style fixes, comments for 4.1.1 authorization Now special 1-byte packet is used for request of old password Fixed bug with --skip-grant-tables and acl_getroot include/mysql.h: removed scramble_323 member as now scramble_323 function does not count on trailing zero for scramble include/mysql_com.h: updated declarations libmysql/libmysql.c: now server sends special 1-byte packet instead of old scramble to re-request password. mysql->scramble_323 replaced with mysql->scramble sql-common/client.c: now server sends special 1-byte packet instead of old scramble to re-request password. mysql->scramble_323 replaces with mysql->scramble sql/password.c: comments beautified hash_password now accepts password length sql/protocol.cc: added send_old_password_request function sql/protocol.h: added send_old_password_request function sql/sql_acl.cc: style fixes, bug with --skip-grant-tables and acl_getroot fixed sql/sql_class.h: thd->scramble_323 removed as now old functions accept not null-terminated scrambles sql/sql_crypt.cc: fixed with new hash_password proto sql/sql_parse.cc: style fixes few comments added --- include/mysql.h | 4 +- include/mysql_com.h | 4 +- libmysql/libmysql.c | 10 +++-- sql-common/client.c | 13 ++++--- sql/password.c | 93 ++++++++++++++++++++++----------------------- sql/protocol.cc | 19 +++++++++ sql/protocol.h | 1 + sql/sql_acl.cc | 54 ++++++++++++++++---------- sql/sql_class.h | 8 +--- sql/sql_crypt.cc | 2 +- sql/sql_parse.cc | 56 ++++++++++++++------------- 11 files changed, 148 insertions(+), 116 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index bf05f6e8e37..079808d9ba7 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -228,8 +228,8 @@ typedef struct st_mysql my_bool free_me; /* If free in mysql_close */ my_bool reconnect; /* set to 1 if automatic reconnect */ - char scramble[SCRAMBLE_LENGTH+1]; /* for new servers */ - char scramble_323[SCRAMBLE_LENGTH_323+1]; /* for old servers */ + /* session-wide random string */ + char scramble[max(SCRAMBLE_LENGTH,SCRAMBLE_LENGTH_323)+1]; /* Set if this is the original connection, not a master or a slave we have diff --git a/include/mysql_com.h b/include/mysql_com.h index e5782235934..87cedafb93d 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -318,9 +318,9 @@ void randominit(struct rand_struct *, unsigned long seed1, double my_rnd(struct rand_struct *); void create_random_string(char *to, uint length, struct rand_struct *rand_st); -void hash_password(ulong *to, const char *password); +void hash_password(ulong *to, const char *password, uint password_len); void make_scrambled_password_323(char *to, const char *password); -char *scramble_323(char *to, const char *message, const char *password); +void scramble_323(char *to, const char *message, const char *password); my_bool check_scramble_323(const char *, const char *message, unsigned long *salt); void get_salt_from_password_323(unsigned long *res, const char *password); diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index ee7fd6a2576..cec9980bae7 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -626,7 +626,10 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, end+= SCRAMBLE_LENGTH; } else - end= scramble_323(end, mysql->scramble_323, passwd); + { + scramble_323(end, mysql->scramble, passwd); + end+= SCRAMBLE_LENGTH_323 + 1; + } } else *end++= '\0'; // empty password @@ -642,15 +645,14 @@ my_bool STDCALL mysql_change_user(MYSQL *mysql, const char *user, if (pkt_length == packet_error) goto error; - if (net->read_pos[0] == mysql->scramble_323[0] && - pkt_length == SCRAMBLE_LENGTH_323 + 1 && + if (pkt_length == 1 && net->read_pos[0] == 254 && mysql->server_capabilities & CLIENT_SECURE_CONNECTION) { /* By sending this very specific reply server asks us to send scrambled password in old format. The reply contains scramble_323. */ - scramble_323(buff, mysql->scramble_323, passwd); + scramble_323(buff, mysql->scramble, passwd); if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) { net->last_errno= CR_SERVER_LOST; diff --git a/sql-common/client.c b/sql-common/client.c index 9a0b7eb3fe2..aac5be4b690 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1641,9 +1641,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, Scramble is split into two parts because old clients does not understand long scrambles; here goes the first part. */ - strmake(mysql->scramble_323, end, SCRAMBLE_LENGTH_323); + strmake(mysql->scramble, end, SCRAMBLE_LENGTH_323); end+= SCRAMBLE_LENGTH_323+1; - memcpy(mysql->scramble, mysql->scramble_323, SCRAMBLE_LENGTH_323); if (pkt_length >= (uint) (end+1 - (char*) net->read_pos)) mysql->server_capabilities=uint2korr(end); @@ -1842,7 +1841,10 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, end+= SCRAMBLE_LENGTH; } else - end= scramble_323(end, mysql->scramble_323, passwd) + 1; + { + scramble_323(end, mysql->scramble, passwd); + end+= SCRAMBLE_LENGTH_323 + 1; + } } else *end++= '\0'; /* empty password */ @@ -1871,15 +1873,14 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, if ((pkt_length=net_safe_read(mysql)) == packet_error) goto error; - if (net->read_pos[0] == mysql->scramble_323[0] && - pkt_length == SCRAMBLE_LENGTH_323 + 1 && + if (pkt_length == 1 && net->read_pos[0] == 254 && mysql->server_capabilities & CLIENT_SECURE_CONNECTION) { /* By sending this very specific reply server asks us to send scrambled password in old format. The reply contains scramble_323. */ - scramble_323(buff, mysql->scramble_323, passwd); + scramble_323(buff, mysql->scramble, passwd); if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) { net->last_errno= CR_SERVER_LOST; diff --git a/sql/password.c b/sql/password.c index 2e9139c12aa..16227aab611 100644 --- a/sql/password.c +++ b/sql/password.c @@ -110,15 +110,17 @@ double my_rnd(struct rand_struct *rand_st) Used for Pre-4.1 password handling SYNOPSIS hash_password() - result OUT store hash in this location - password IN plain text password to build hash + result OUT store hash in this location + password IN plain text password to build hash + password_len IN password length (password may be not null-terminated) */ -void hash_password(ulong *result, const char *password) +void hash_password(ulong *result, const char *password, uint password_len) { register ulong nr=1345345333L, add=7, nr2=0x12345671L; ulong tmp; - for (; *password ; password++) + const char *password_end= password + password_len; + for (; password < password_end; password++) { if (*password == ' ' || *password == '\t') continue; /* skip space in password */ @@ -129,7 +131,6 @@ void hash_password(ulong *result, const char *password) } result[0]=nr & (((ulong) 1L << 31) -1L); /* Don't use sign bit (str2int) */; result[1]=nr2 & (((ulong) 1L << 31) -1L); - return; } @@ -145,7 +146,7 @@ void hash_password(ulong *result, const char *password) void make_scrambled_password_323(char *to, const char *password) { ulong hash_res[2]; - hash_password(hash_res, password); + hash_password(hash_res, password, strlen(password)); sprintf(to, "%08lx%08lx", hash_res[0], hash_res[1]); } @@ -157,14 +158,12 @@ void make_scrambled_password_323(char *to, const char *password) scramble_323() to OUT Store scrambled message here. Buffer must be at least SCRAMBLE_LENGTH_323+1 bytes long - message IN Message to scramble. Message must be exactly - SRAMBLE_LENGTH_323 long and NULL terminated. + message IN Message to scramble. Message must be at least + SRAMBLE_LENGTH_323 bytes long. password IN Password to use while scrambling - RETURN - End of scrambled string */ -char *scramble_323(char *to, const char *message, const char *password) +void scramble_323(char *to, const char *message, const char *password) { struct rand_struct rand_st; ulong hash_pass[2], hash_message[2]; @@ -172,18 +171,18 @@ char *scramble_323(char *to, const char *message, const char *password) if (password && password[0]) { char *to_start=to; - hash_password(hash_pass,password); - hash_password(hash_message, message); + hash_password(hash_pass,password, strlen(password)); + hash_password(hash_message, message, SCRAMBLE_LENGTH_323); randominit(&rand_st,hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1]); - while (*message++) + const char *message_end= message + SCRAMBLE_LENGTH_323; + for (; message < message_end; message++) *to++= (char) (floor(my_rnd(&rand_st)*31)+64); char extra=(char) (floor(my_rnd(&rand_st)*31)); while (to_start != to) *(to_start++)^=extra; } *to= 0; - return to; } @@ -192,11 +191,13 @@ char *scramble_323(char *to, const char *message, const char *password) Used in pre 4.1 password handling SYNOPSIS check_scramble_323() - scrambled IN scrambled message to check. - message IN original random message which was used for scrambling; must - be exactly SCRAMBLED_LENGTH_323 bytes long and - NULL-terminated. - hash_pass IN password which should be used for scrambling + scrambled scrambled message to check. + message original random message which was used for scrambling; must + be exactly SCRAMBLED_LENGTH_323 bytes long and + NULL-terminated. + hash_pass password which should be used for scrambling + All params are IN. + RETURN VALUE 0 - password correct !0 - password invalid @@ -211,11 +212,7 @@ check_scramble_323(const char *scrambled, const char *message, char buff[16],*to,extra; /* Big enough for check */ const char *pos; - /* Check if this exactly N bytes. Overwise this is something fishy */ - if (strlen(message) != SCRAMBLE_LENGTH_323) - return 1; /* Wrong password */ - - hash_password(hash_message,message); + hash_password(hash_message, message, SCRAMBLE_LENGTH_323); randominit(&rand_st,hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1]); to=buff; @@ -231,7 +228,7 @@ check_scramble_323(const char *scrambled, const char *message, return 0; } -static uint8 char_val(uint8 X) +static inline uint8 char_val(uint8 X) { return (uint) (X >= '0' && X <= '9' ? X-'0' : X >= 'A' && X <= 'Z' ? X-'A'+10 : X-'a'+10); @@ -280,7 +277,10 @@ void make_password_from_salt_323(char *to, const ulong *salt) } -/******************* MySQL 4.1.1 authentification routines ******************/ +/* + **************** MySQL 4.1.1 authentification routines ************* +*/ + /* Generate string of printable random characters of requested length SYNOPSIS @@ -315,19 +315,16 @@ void create_random_string(char *to, uint length, struct rand_struct *rand_st) str, len IN the beginning and the length of the input string */ -static -void +static void octet2hex(char *to, const uint8 *str, uint len) { - static const char alphabet[] = { '0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; const uint8 *str_end= str + len; for (; str != str_end; ++str) { - *to++= alphabet[(*str & 0xF0) >> 4]; - *to++= alphabet[*str & 0x0F]; + *to++= _dig_vec[(*str & 0xF0) >> 4]; + *to++= _dig_vec[*str & 0x0F]; } - *to++= '\0'; + *to= '\0'; } @@ -341,15 +338,14 @@ octet2hex(char *to, const uint8 *str, uint len) overlap; len % 2 == 0 */ -static -void +static void hex2octet(uint8 *to, const char *str, uint len) { const char *str_end= str + len; while (str < str_end) { - *to= char_val(*str++) << 4; - *to++|= char_val(*str++); + register char tmp= char_val(*str++); + *to++= (tmp << 4) | char_val(*str++); } } @@ -366,9 +362,8 @@ hex2octet(uint8 *to, const char *str, uint len) len IN length of s1 and s2 */ -static -void -my_crypt(char *to, const uint8 *s1, const uint8 *s2, uint len) +static void +my_crypt(char *to, const uchar *s1, const uchar *s2, uint len) { const uint8 *s1_end= s1 + len; while (s1 < s1_end) @@ -447,7 +442,7 @@ scramble(char *to, const char *message, const char *password) sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE); /* xor allows 'from' and 'to' overlap: lets take advantage of it */ sha1_result(&sha1_context, (uint8 *) to); - my_crypt(to, (const uint8 *) to, hash_stage1, SCRAMBLE_LENGTH); + my_crypt(to, (const uchar *) to, hash_stage1, SCRAMBLE_LENGTH); } @@ -459,11 +454,13 @@ scramble(char *to, const char *message, const char *password) long (if not, something fishy is going on). SYNOPSIS check_scramble() - scramble IN clients' reply, presumably produced by scramble() - message IN original random string, previously sent to client - (presumably second argument of scramble()), must be - exactly SCRAMBLE_LENGTH long and NULL-terminated. - hash_stage2 IN hex2octet-decoded database entry + scramble clients' reply, presumably produced by scramble() + message original random string, previously sent to client + (presumably second argument of scramble()), must be + exactly SCRAMBLE_LENGTH long and NULL-terminated. + hash_stage2 hex2octet-decoded database entry + All params are IN. + RETURN VALUE 0 password is correct !0 password is invalid @@ -483,7 +480,7 @@ check_scramble(const char *scramble, const char *message, sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE); sha1_result(&sha1_context, buf); /* encrypt scramble */ - my_crypt((char *) buf, buf, (const uint8 *) scramble, SCRAMBLE_LENGTH); + my_crypt((char *) buf, buf, (const uchar *) scramble, SCRAMBLE_LENGTH); /* now buf supposedly contains hash_stage1: so we can get hash_stage2 */ sha1_reset(&sha1_context); sha1_input(&sha1_context, buf, SHA1_HASH_SIZE); diff --git a/sql/protocol.cc b/sql/protocol.cc index 1b9256c7723..7e009aa6a17 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -348,6 +348,25 @@ send_eof(THD *thd, bool no_flush) } DBUG_VOID_RETURN; } + +/* + Please client to send scrambled_password in old format. + SYNOPSYS + send_old_password_request() + thd thread handle + + RETURN VALUE + 0 ok + !0 error +*/ + +bool send_old_password_request(THD *thd) +{ + static char buff[1]= { (char) 254 }; + NET *net= &thd->net; + return my_net_write(net, buff, 1) || net_flush(net); +} + #endif /* EMBEDDED_LIBRARY */ diff --git a/sql/protocol.h b/sql/protocol.h index ffd61b3e848..405d3d4aebe 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -164,6 +164,7 @@ void net_printf(THD *thd,uint sql_errno, ...); void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, const char *info=0); void send_eof(THD *thd, bool no_flush=0); +bool send_old_password_request(THD *thd); char *net_store_length(char *packet,ulonglong length); char *net_store_length(char *packet,uint length); char *net_store_data(char *to,const char *from, uint length); diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index ee544335a99..fafe725201d 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -264,10 +264,11 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables) { switch (password_len) { case 45: /* 4.1: to be removed */ - sql_print_error("Found 4.1 style password for user '%s'. " + sql_print_error("Found 4.1 style password for user '%s@%s'. " "Ignoring user. " "You should change password for this user.", - user.user ? user.user : ""); + user.user ? user.user : "", + user.host.hostname ? user.host.hostname : ""); break; default: sql_print_error("Found invalid password for user: '%s@%s'; " @@ -526,23 +527,30 @@ static int acl_compare(ACL_ACCESS *a,ACL_ACCESS *b) /* Seek ACL entry for a user, check password, SSL cypher, and if everything is OK, update THD user data and USER_RESOURCES struct. + + IMPLEMENTATION This function does not check if the user has any sensible privileges: only user's existence and validity is checked. Note, that entire operation is protected by acl_cache_lock. + SYNOPSIS - thd INOUT thread handle. If all checks are OK, - thd->priv_user, thd->master_access are updated. - thd->host, thd->ip, thd->user are used for checks. - mqh OUT user resources; on success mqh is reset, else - unchanged - passwd IN scrambled & crypted password, recieved from client - (to check): thd->scramble or thd->scramble_323 is - used to decrypt passwd, so they must contain - original random string, - passwd_len IN length of passwd, must be one of 0, 8, - SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH + acl_getroot() + thd thread handle. If all checks are OK, + thd->priv_user, thd->master_access are updated. + thd->host, thd->ip, thd->user are used for checks. + mqh user resources; on success mqh is reset, else + unchanged + passwd scrambled & crypted password, recieved from client + (to check): thd->scramble or thd->scramble_323 is + used to decrypt passwd, so they must contain + original random string, + passwd_len length of passwd, must be one of 0, 8, + SCRAMBLE_LENGTH_323, SCRAMBLE_LENGTH + 'thd' and 'mqh' are updated on success; other params are IN. + RETURN VALUE - 0 success: thread data and mqh are updated + 0 success: thd->priv_user, thd->priv_host, thd->master_access, mqh are + updated 1 user not found or authentification failure 2 user found, has long (4.1.1) salt, but passwd is in old (3.23) format. -1 user found, has short (3.23) salt, but passwd is in new (4.1.1) format. @@ -553,9 +561,16 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, { DBUG_ENTER("acl_getroot"); - if (!initialized) /* if no data allow anything */ - { - DBUG_RETURN(1); + if (!initialized) + { + /* + here if mysqld's been started with --skip-grant-tables option. + */ + thd->priv_user= (char *) ""; // privileges for + *thd->priv_host= '\0'; // the user are unknown + thd->master_access= ~NO_ACCESS; // everything is allowed + bzero(mqh, sizeof(*mqh)); + DBUG_RETURN(0); } int res= 1; @@ -582,7 +597,7 @@ int acl_getroot(THD *thd, USER_RESOURCES *mqh, if (user_i->salt_len == 0 || user_i->salt_len == SCRAMBLE_LENGTH && check_scramble(passwd, thd->scramble, user_i->salt) == 0 || - check_scramble_323(passwd, thd->scramble_323, + check_scramble_323(passwd, thd->scramble, (ulong *) user_i->salt) == 0) { acl_user= user_i; @@ -1346,8 +1361,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, { int error = -1; bool old_row_exists=0; - char empty_string[]= { '\0' }; - char *password= empty_string; + const char *password= ""; uint password_len= 0; char what= (revoke_grant) ? 'N' : 'Y'; DBUG_ENTER("replace_user_table"); diff --git a/sql/sql_class.h b/sql/sql_class.h index e80b5d9c8d5..1557ede8305 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -547,13 +547,7 @@ public: DYNAMIC_ARRAY user_var_events; /* scramble - random string sent to client on handshake */ - char scramble[SCRAMBLE_LENGTH+1]; - /* - The same as scramble but for old password checking routines. It always - contains first N bytes of scramble. - See check_connection() at sql_parse.cc for authentification details. - */ - char scramble_323[SCRAMBLE_LENGTH_323+1]; + char scramble[max(SCRAMBLE_LENGTH, SCRAMBLE_LENGTH_323)+1]; uint8 query_cache_type; // type of query cache processing bool slave_thread; diff --git a/sql/sql_crypt.cc b/sql/sql_crypt.cc index 930ecfffef7..b0b8050e311 100644 --- a/sql/sql_crypt.cc +++ b/sql/sql_crypt.cc @@ -32,7 +32,7 @@ SQL_CRYPT::SQL_CRYPT(const char *password) { ulong rand_nr[2]; - hash_password(rand_nr,password); + hash_password(rand_nr,password, strlen(password)); crypt_init(rand_nr); } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 7878f2c8a29..9d75029a997 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -181,17 +181,20 @@ end: Check if user exist and password supplied is correct. SYNOPSIS check_user() - thd INOUT thread handle, thd->{host,user,ip} are used - command IN originator of the check: now check_user is called - during connect and change user procedures; used for - logging. - passwd IN scrambled password recieved from client - passwd_len IN length of scrambled password - db IN database name to connect to, may be NULL - check_count IN dont know exactly + thd thread handle, thd->{host,user,ip} are used + command originator of the check: now check_user is called + during connect and change user procedures; used for + logging. + passwd scrambled password recieved from client + passwd_len length of scrambled password + db database name to connect to, may be NULL + check_count dont know exactly + Note, that host, user and passwd may point to communication buffer. Current implementation does not depened on that, but future changes - should be done with this in mind. + should be done with this in mind; 'thd' is INOUT, all other params + are 'IN'. + RETURN VALUE 0 OK; thd->user, thd->master_access, thd->priv_user, thd->db and thd->db_access are updated; OK is sent to client; @@ -226,8 +229,10 @@ static int check_user(THD *thd, enum enum_server_command command, DBUG_RETURN(ER_HANDSHAKE_ERROR); /* - Why this is set here? - probably to reset current DB to 'no database - selected' in case of 'change user' failure. + Clear thd->db as it points to something, that will be freed when + connection is closed. We don't want to accidently free a wrong pointer + if connect failed. Also in case of 'CHANGE USER' failure, current + database will be switched to 'no database selected'. */ thd->db= 0; thd->db_length= 0; @@ -244,6 +249,7 @@ static int check_user(THD *thd, enum enum_server_command command, scramble_323()). Here we please client to send scrambled_password in old format. */ + NET *net= &thd->net; if (opt_secure_auth_local) { net_printf(thd, ER_SERVER_IS_IN_SECURE_AUTH_MODE, @@ -258,9 +264,7 @@ static int check_user(THD *thd, enum enum_server_command command, strmake(buff, db, NAME_LEN); db= buff; } - NET *net= &thd->net; - if (my_net_write(net, thd->scramble_323, SCRAMBLE_LENGTH_323 + 1) || - net_flush(net) || + if (send_old_password_request(thd) || my_net_read(net) != SCRAMBLE_LENGTH_323 + 1) // We have to read very { // specific packet size inc_host_errors(&thd->remote.sin_addr); @@ -288,7 +292,7 @@ static int check_user(THD *thd, enum enum_server_command command, { VOID(pthread_mutex_lock(&LOCK_thread_count)); bool count_ok= thread_count < max_connections + delayed_insert_threads - || thd->master_access & SUPER_ACL; + || (thd->master_access & SUPER_ACL); VOID(pthread_mutex_unlock(&LOCK_thread_count)); if (!count_ok) { // too many connections @@ -305,7 +309,11 @@ static int check_user(THD *thd, enum enum_server_command command, thd->user, thd->host_or_ip, db ? db : (char*) ""); - /* Why is it set here? */ + /* + This is the default access rights for the current database. It's + set to 0 here because we don't have an active database yet (and we + may not have an active database to set. + */ thd->db_access=0; /* Don't allow user to connect if he has done too many queries */ @@ -554,9 +562,10 @@ static void reset_mqh(THD *thd, LEX_USER *lu, bool get_them= 0) Perform handshake, authorize client and update thd ACL variables. SYNOPSIS check_connection() - thd INOUT thread handle + thd thread handle + RETURN - 0 success, OK is sent to user + 0 success, OK is sent to user, thd is updated. -1 error, which is sent to user > 0 error code (not sent to user) */ @@ -644,14 +653,12 @@ check_connection(THD *thd) each handshake. */ create_random_string(thd->scramble, SCRAMBLE_LENGTH, &thd->rand); - strmake(thd->scramble_323, thd->scramble, SCRAMBLE_LENGTH_323); - /* Old clients does not understand long scrambles, but can ignore packet tail: that's why first part of the scramble is placed here, and second part at the end of packet. */ - end= strmake(end, thd->scramble_323, SCRAMBLE_LENGTH_323) + 1; + end= strmake(end, thd->scramble, SCRAMBLE_LENGTH_323) + 1; int2store(end, client_flags); /* write server characteristics: up to 16 bytes allowed */ @@ -754,8 +761,6 @@ check_connection(THD *thd) return(ER_HANDSHAKE_ERROR); } - /* why has it been put here? */ - if (thd->client_capabilities & CLIENT_INTERACTIVE) thd->variables.net_wait_timeout= thd->variables.net_interactive_timeout; if ((thd->client_capabilities & CLIENT_TRANSACTIONS) && @@ -778,9 +783,8 @@ check_connection(THD *thd) if (thd->user) x_free(thd->user); - thd->user= my_strdup(user, MYF(0)); - if (!thd->user) - return(ER_OUT_OF_RESOURCES); + if (!(thd->user= my_strdup(user, MYF(0)))) + return (ER_OUT_OF_RESOURCES); return check_user(thd, COM_CONNECT, passwd, passwd_len, db, true); } From 4df473b81c92be37364abaa83b0bafe21fc135a4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 18 Jul 2003 18:57:21 +0400 Subject: [PATCH 007/282] few compile-time bugs fixed include/mysql.h: fixed compile-time bug sql/sql_class.cc: fixed compile-time bug sql/sql_class.h: fixed compile-time bug --- include/mysql.h | 2 +- sql/sql_class.cc | 2 +- sql/sql_class.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/mysql.h b/include/mysql.h index 079808d9ba7..10bacffb2b1 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -229,7 +229,7 @@ typedef struct st_mysql my_bool reconnect; /* set to 1 if automatic reconnect */ /* session-wide random string */ - char scramble[max(SCRAMBLE_LENGTH,SCRAMBLE_LENGTH_323)+1]; + char scramble[SCRAMBLE_LENGTH+1]; /* Set if this is the original connection, not a master or a slave we have diff --git a/sql/sql_class.cc b/sql/sql_class.cc index ebb3e819ddc..c7fb2ce3368 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -139,7 +139,7 @@ THD::THD():user_time(0), is_fatal_error(0), set_query_id=1; db_access=NO_ACCESS; version=refresh_version; // For boot - *scramble= *scramble_323= '\0'; + *scramble= '\0'; init(); /* Initialize sub structures */ diff --git a/sql/sql_class.h b/sql/sql_class.h index 1557ede8305..4eb1d6057a9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -547,7 +547,7 @@ public: DYNAMIC_ARRAY user_var_events; /* scramble - random string sent to client on handshake */ - char scramble[max(SCRAMBLE_LENGTH, SCRAMBLE_LENGTH_323)+1]; + char scramble[SCRAMBLE_LENGTH+1]; uint8 query_cache_type; // type of query cache processing bool slave_thread; From d289accb0af491ae0d241fa801c291da07fabd77 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Jul 2003 17:36:56 +0300 Subject: [PATCH 008/282] Fuller implementation of lower case table names. Bug record #828 --- mysql-test/r/lowercase_table.result | 3 ++- mysql-test/t/lowercase_table.test | 1 - sql/mysql_priv.h | 6 ++++++ sql/sql_class.h | 12 +++++++++--- sql/sql_parse.cc | 2 ++ sql/sql_table.cc | 2 ++ sql/sql_yacc.yy | 4 ++++ 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/mysql-test/r/lowercase_table.result b/mysql-test/r/lowercase_table.result index d32228216b8..c884e5de0f0 100644 --- a/mysql-test/r/lowercase_table.result +++ b/mysql-test/r/lowercase_table.result @@ -21,7 +21,8 @@ select count(*) from t1; count(*) 0 select count(T1.a) from t1; -Unknown table 'T1' in field list +count(T1.a) +0 select count(bags.a) from t1 as Bags; Unknown table 'bags' in field list drop table t1; diff --git a/mysql-test/t/lowercase_table.test b/mysql-test/t/lowercase_table.test index b3453dfd3c4..397cc26e127 100644 --- a/mysql-test/t/lowercase_table.test +++ b/mysql-test/t/lowercase_table.test @@ -18,7 +18,6 @@ drop table t3; create table t1 (a int); select count(*) from T1; select count(*) from t1; ---error 1109 select count(T1.a) from t1; --error 1109 select count(bags.a) from t1 as Bags; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 0a4728ef325..adbf344fda6 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -862,3 +862,9 @@ inline void mark_as_null_row(TABLE *table) table->status|=STATUS_NULL_ROW; bfill(table->null_flags,table->null_bytes,255); } + +inline void table_case_convert(char * name, uint length) +{ + if (lower_case_table_names) + casedn(name, length); +} diff --git a/sql/sql_class.h b/sql/sql_class.h index dcc839e13b1..5e4e6184328 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -33,7 +33,7 @@ enum enum_duplicates { DUP_ERROR, DUP_REPLACE, DUP_IGNORE }; enum enum_log_type { LOG_CLOSED, LOG_TO_BE_OPENED, LOG_NORMAL, LOG_NEW, LOG_BIN}; enum enum_delay_key_write { DELAY_KEY_WRITE_NONE, DELAY_KEY_WRITE_ON, DELAY_KEY_WRITE_ALL }; - +extern inline void table_case_convert(char * name, uint length); /* log info errors */ #define LOG_INFO_EOF -1 #define LOG_INFO_IO -2 @@ -758,7 +758,6 @@ typedef struct st_sort_buffer { SORT_FIELD *sortorder; } SORT_BUFFER; - /* Structure for db & table in sql_yacc */ class Table_ident :public Sql_alloc { @@ -772,8 +771,15 @@ class Table_ident :public Sql_alloc { db.str=0; else db= db_arg; + if (db.str) + table_case_convert(db.str,db.length); + table_case_convert(table.str,table.length); + } + inline Table_ident(LEX_STRING table_arg) :table(table_arg) + { + db.str=0; + table_case_convert(table.str,table.length); } - inline Table_ident(LEX_STRING table_arg) :table(table_arg) {db.str=0;} inline void change_db(char *db_name) { db.str= db_name; db.length=(uint) strlen(db_name); } }; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 70c0f772d7d..509f3ee5736 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3385,8 +3385,10 @@ TABLE_LIST *add_table_to_list(Table_ident *table, LEX_STRING *alias, } ptr->alias= alias_str; +#ifdef TO_BE_DELETED if (lower_case_table_names) casedn_str(table->table.str); +#endif ptr->real_name=table->table.str; ptr->real_name_length=table->table.length; ptr->lock_type= lock_type; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index cf430aec35d..b2b8c7d7140 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1459,8 +1459,10 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, { strmov(new_name_buff,new_name); fn_same(new_name_buff,table_name,3); +#ifdef TO_BE_DELETED if (lower_case_table_names) casedn_str(new_name); +#endif if ((lower_case_table_names && !my_strcasecmp(new_name_buff,table_name)) || (!lower_case_table_names && diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b07dca91a20..d67f76ea66b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3221,16 +3221,20 @@ simple_ident: | ident '.' ident { SELECT_LEX *sel=Select; + table_case_convert($1.str, $1.length); $$ = !sel->create_refs || sel->in_sum_expr > 0 ? (Item*) new Item_field(NullS,$1.str,$3.str) : (Item*) new Item_ref(NullS,$1.str,$3.str); } | '.' ident '.' ident { SELECT_LEX *sel=Select; + table_case_convert($2.str,$2.length); $$ = !sel->create_refs || sel->in_sum_expr > 0 ? (Item*) new Item_field(NullS,$2.str,$4.str) : (Item*) new Item_ref(NullS,$2.str,$4.str); } | ident '.' ident '.' ident { SELECT_LEX *sel=Select; + table_case_convert($1.str,$1.length); + table_case_convert($3.str,$3.length); $$ = !sel->create_refs || sel->in_sum_expr > 0 ? (Item*) new Item_field((current_thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str) : (Item*) new Item_ref((current_thd->client_capabilities & CLIENT_NO_SCHEMA ? NullS :$1.str),$3.str,$5.str); }; From 7ec21e9fc4d2311a421f3a4a9c726e394327910b Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 Jul 2003 01:02:42 +0300 Subject: [PATCH 009/282] added warning about external fields resolving to EXPLAIN command (SCRUM) (WL#1053) include/mysqld_error.h: new warning mysql-test/r/subselect.result: new warning sql/item.cc: warning for external fields resolving sql/share/czech/errmsg.txt: new warning sql/share/danish/errmsg.txt: new warning sql/share/dutch/errmsg.txt: new warning sql/share/english/errmsg.txt: new warning sql/share/estonian/errmsg.txt: new warning sql/share/french/errmsg.txt: new warning sql/share/german/errmsg.txt: new warning sql/share/greek/errmsg.txt: new warning sql/share/hungarian/errmsg.txt: new warning sql/share/italian/errmsg.txt: new warning sql/share/japanese/errmsg.txt: new warning sql/share/korean/errmsg.txt: new warning sql/share/norwegian-ny/errmsg.txt: new warning sql/share/norwegian/errmsg.txt: new warning sql/share/polish/errmsg.txt: new warning sql/share/portuguese/errmsg.txt: new warning sql/share/romanian/errmsg.txt: new warning sql/share/russian/errmsg.txt: new warning sql/share/serbian/errmsg.txt: new warning sql/share/slovak/errmsg.txt: new warning sql/share/spanish/errmsg.txt: new warning sql/share/swedish/errmsg.txt: new warning sql/share/ukrainian/errmsg.txt: new warning --- include/mysqld_error.h | 3 ++- mysql-test/r/subselect.result | 11 +++++++++++ sql/item.cc | 25 +++++++++++++++++++------ sql/share/czech/errmsg.txt | 1 + sql/share/danish/errmsg.txt | 1 + sql/share/dutch/errmsg.txt | 1 + sql/share/english/errmsg.txt | 1 + sql/share/estonian/errmsg.txt | 1 + sql/share/french/errmsg.txt | 1 + sql/share/german/errmsg.txt | 1 + sql/share/greek/errmsg.txt | 1 + sql/share/hungarian/errmsg.txt | 1 + sql/share/italian/errmsg.txt | 1 + sql/share/japanese/errmsg.txt | 1 + sql/share/korean/errmsg.txt | 1 + sql/share/norwegian-ny/errmsg.txt | 1 + sql/share/norwegian/errmsg.txt | 1 + sql/share/polish/errmsg.txt | 1 + sql/share/portuguese/errmsg.txt | 1 + sql/share/romanian/errmsg.txt | 1 + sql/share/russian/errmsg.txt | 1 + sql/share/serbian/errmsg.txt | 1 + sql/share/slovak/errmsg.txt | 1 + sql/share/spanish/errmsg.txt | 1 + sql/share/swedish/errmsg.txt | 1 + sql/share/ukrainian/errmsg.txt | 1 + 26 files changed, 55 insertions(+), 7 deletions(-) diff --git a/include/mysqld_error.h b/include/mysqld_error.h index 0468663239b..b8a90c31a68 100644 --- a/include/mysqld_error.h +++ b/include/mysqld_error.h @@ -287,4 +287,5 @@ #define ER_CANT_AGGREGATE_3COLLATIONS 1268 #define ER_CANT_AGGREGATE_NCOLLATIONS 1269 #define ER_VARIABLE_IS_NOT_STRUCT 1270 -#define ER_ERROR_MESSAGES 271 +#define ER_WARN_FIELD_RESOLVED 1271 +#define ER_ERROR_MESSAGES 272 diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index e941c115b2c..dea79868dac 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -42,6 +42,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY system NULL NULL NULL NULL 1 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1271 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 +Note 1271 Field or reference '.a' of SELECT #3 was resolved in SELECT #1 SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -207,6 +210,8 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t4 ALL NULL NULL NULL NULL 3 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where +Warnings: +Note 1271 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -286,6 +291,9 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t2 ALL NULL NULL NULL NULL 2 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where +Warnings: +Note 1271 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 +Note 1271 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subselect returns more than 1 record create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -301,6 +309,8 @@ explain select * from t6 where exists (select * from t7 where uq = clinic_uq); id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 +Warnings: +Note 1271 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column: 'a' in field list is ambiguous drop table if exists t1,t2,t3; @@ -808,6 +818,7 @@ explain select (select a+1) from t1; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 3 Warnings: +Note 1271 Field or reference 'a' of SELECT #2 was resolved in SELECT #1 Note 1247 Select 2 was reduced during optimisation select (select a+1) from t1; (select a+1) diff --git a/sql/item.cc b/sql/item.cc index c7d0927c970..57769d40fed 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -23,7 +23,8 @@ #include #include "my_dir.h" -static void mark_as_dependent(SELECT_LEX *last, SELECT_LEX *current, +static void mark_as_dependent(THD *thd, + SELECT_LEX *last, SELECT_LEX *current, Item_ident *item); /***************************************************************************** @@ -810,17 +811,29 @@ bool Item_ref_null_helper::get_date(TIME *ltime, bool fuzzydate) SYNOPSIS mark_as_dependent() + thd - thread handler last - select from which current item depend current - current select item - item which should be marked */ -static void mark_as_dependent(SELECT_LEX *last, SELECT_LEX *current, +static void mark_as_dependent(THD *thd, SELECT_LEX *last, SELECT_LEX *current, Item_ident *item) { // store pointer on SELECT_LEX from wich item is dependent item->depended_from= last; current->mark_as_dependent(last); + if (thd->lex.describe) + { + char warn_buff[MYSQL_ERRMSG_SIZE]; + sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED), + (item->db_name?item->db_name:""), (item->db_name?".":""), + (item->table_name?item->table_name:""), (item->table_name?".":""), + item->field_name, + current->select_number, last->select_number); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE, + ER_WARN_FIELD_RESOLVED, warn_buff); + } } @@ -902,12 +915,12 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (rf->fix_fields(thd, tables, ref) || rf->check_cols(1)) return 1; - mark_as_dependent(last, cursel, rf); + mark_as_dependent(thd, last, cursel, rf); return 0; } else { - mark_as_dependent(last, cursel, this); + mark_as_dependent(thd, last, cursel, this); if (last->having_fix_field) { Item_ref *rf; @@ -1379,7 +1392,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) Item_field* fld; if (!((*reference)= fld= new Item_field(tmp))) return 1; - mark_as_dependent(last, thd->lex.current_select, fld); + mark_as_dependent(thd, last, thd->lex.current_select, fld); return 0; } else @@ -1390,7 +1403,7 @@ bool Item_ref::fix_fields(THD *thd,TABLE_LIST *tables, Item **reference) "forward reference in item list"); return -1; } - mark_as_dependent(last, thd->lex.current_select, + mark_as_dependent(thd, last, thd->lex.current_select, this); ref= last->ref_pointer_array + counter; } diff --git a/sql/share/czech/errmsg.txt b/sql/share/czech/errmsg.txt index 6f42243ba2b..b47258fd07b 100644 --- a/sql/share/czech/errmsg.txt +++ b/sql/share/czech/errmsg.txt @@ -276,3 +276,4 @@ v/* "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/danish/errmsg.txt b/sql/share/danish/errmsg.txt index 25a5020a30f..56b36b98c30 100644 --- a/sql/share/danish/errmsg.txt +++ b/sql/share/danish/errmsg.txt @@ -270,3 +270,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/dutch/errmsg.txt b/sql/share/dutch/errmsg.txt index 6aba93c246c..80d931b4ab7 100644 --- a/sql/share/dutch/errmsg.txt +++ b/sql/share/dutch/errmsg.txt @@ -278,3 +278,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/english/errmsg.txt b/sql/share/english/errmsg.txt index 11ae2c89019..66052ff6c9a 100644 --- a/sql/share/english/errmsg.txt +++ b/sql/share/english/errmsg.txt @@ -272,3 +272,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/estonian/errmsg.txt b/sql/share/estonian/errmsg.txt index 94e19fc6e9d..0d13c6fe237 100644 --- a/sql/share/estonian/errmsg.txt +++ b/sql/share/estonian/errmsg.txt @@ -272,3 +272,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/french/errmsg.txt b/sql/share/french/errmsg.txt index dd062cc074a..8616f0ed485 100644 --- a/sql/share/french/errmsg.txt +++ b/sql/share/french/errmsg.txt @@ -267,3 +267,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/german/errmsg.txt b/sql/share/german/errmsg.txt index e7cdf3f6f0d..1850dd5e95f 100644 --- a/sql/share/german/errmsg.txt +++ b/sql/share/german/errmsg.txt @@ -276,3 +276,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/greek/errmsg.txt b/sql/share/greek/errmsg.txt index ef423ae2758..d1a69677c81 100644 --- a/sql/share/greek/errmsg.txt +++ b/sql/share/greek/errmsg.txt @@ -267,3 +267,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/hungarian/errmsg.txt b/sql/share/hungarian/errmsg.txt index 6b27cdc2551..dd1c6c6eba7 100644 --- a/sql/share/hungarian/errmsg.txt +++ b/sql/share/hungarian/errmsg.txt @@ -269,3 +269,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/italian/errmsg.txt b/sql/share/italian/errmsg.txt index 8b0598f64b5..69b605e2185 100644 --- a/sql/share/italian/errmsg.txt +++ b/sql/share/italian/errmsg.txt @@ -267,3 +267,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/japanese/errmsg.txt b/sql/share/japanese/errmsg.txt index 011d6a1faac..10e295894e6 100644 --- a/sql/share/japanese/errmsg.txt +++ b/sql/share/japanese/errmsg.txt @@ -269,3 +269,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/korean/errmsg.txt b/sql/share/korean/errmsg.txt index be7fee7cb45..37182e3514c 100644 --- a/sql/share/korean/errmsg.txt +++ b/sql/share/korean/errmsg.txt @@ -267,3 +267,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/norwegian-ny/errmsg.txt b/sql/share/norwegian-ny/errmsg.txt index 96c11871502..faae05934ba 100644 --- a/sql/share/norwegian-ny/errmsg.txt +++ b/sql/share/norwegian-ny/errmsg.txt @@ -269,3 +269,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/norwegian/errmsg.txt b/sql/share/norwegian/errmsg.txt index c505d512e9e..f131ab0baef 100644 --- a/sql/share/norwegian/errmsg.txt +++ b/sql/share/norwegian/errmsg.txt @@ -269,3 +269,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/polish/errmsg.txt b/sql/share/polish/errmsg.txt index 33b2fbdb8a8..a3759da317b 100644 --- a/sql/share/polish/errmsg.txt +++ b/sql/share/polish/errmsg.txt @@ -271,3 +271,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index e8a3205ec5d..b3833b3583b 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -267,3 +267,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/romanian/errmsg.txt b/sql/share/romanian/errmsg.txt index 6602b5d430c..1ba2ac8ec49 100644 --- a/sql/share/romanian/errmsg.txt +++ b/sql/share/romanian/errmsg.txt @@ -271,3 +271,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/russian/errmsg.txt b/sql/share/russian/errmsg.txt index 70ff979bfdf..17ea1dfcf6e 100644 --- a/sql/share/russian/errmsg.txt +++ b/sql/share/russian/errmsg.txt @@ -269,3 +269,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"ðÏÌÅ ÉÌÉ ÓÓÙÌËÁ '%-.64s%s%-.64s%s%-.64s' ÉÚ SELECTÁ #%d ÂÙÌÁ ÎÁÊÄÅÎÁ × SELECTÅ #%d", diff --git a/sql/share/serbian/errmsg.txt b/sql/share/serbian/errmsg.txt index f4ea3ac3c82..8e9512f5567 100644 --- a/sql/share/serbian/errmsg.txt +++ b/sql/share/serbian/errmsg.txt @@ -263,3 +263,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/slovak/errmsg.txt b/sql/share/slovak/errmsg.txt index 2ba4f2f0548..f49ff1a2adc 100644 --- a/sql/share/slovak/errmsg.txt +++ b/sql/share/slovak/errmsg.txt @@ -275,3 +275,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index c7f8d51dee9..9f3aa3dd478 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -268,3 +268,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/swedish/errmsg.txt b/sql/share/swedish/errmsg.txt index 0d51cb4b543..ab2cc1f66b0 100644 --- a/sql/share/swedish/errmsg.txt +++ b/sql/share/swedish/errmsg.txt @@ -267,3 +267,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"Field or reference '%-.64s%s%-.64s%s%-.64s' of SELECT #%d was resolved in SELECT #%d", diff --git a/sql/share/ukrainian/errmsg.txt b/sql/share/ukrainian/errmsg.txt index 4e22dbfcf3e..bfa1d0db9e4 100644 --- a/sql/share/ukrainian/errmsg.txt +++ b/sql/share/ukrainian/errmsg.txt @@ -272,3 +272,4 @@ "Illegal mix of collations (%s,%s), (%s,%s), (%s,%s) for operation '%s'", "Illegal mix of collations for operation '%s'", "Variable '%-.64s' is not a variable component (Can't be used as XXXX.variable_name)", +"óÔÏ×ÂÅÃØ ÁÂÏ ÐÏÓÉÌÁÎÎÑ '%-.64s%s%-.64s%s%-.64s' ¦Ú SELECTÕ #%d ÂÕÌÏ ÚÎÁÊÄÅÎÅ Õ SELECT¦ #%d", From ecc7001fbfc1b30a1bbd856b7a093045ccdf3c00 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Jul 2003 21:21:42 +0200 Subject: [PATCH 010/282] INSTALL-WIN-SOURCE: Change mode to -rw-rw-r-- INSTALL-WIN-SOURCE: Change mode to -rw-rw-r-- --- INSTALL-WIN-SOURCE | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 INSTALL-WIN-SOURCE diff --git a/INSTALL-WIN-SOURCE b/INSTALL-WIN-SOURCE old mode 100755 new mode 100644 From d4494c9f21a4650a9d82cd00d0bd7c7412c58d5e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Jul 2003 04:14:36 +0600 Subject: [PATCH 011/282] BUG Add functions SetFilePointerEx and SetEndOfFile for huge tables instead of chsize Move chsize to right place include/config-win.h: add HAVE_SETFILEPOINTER mysys/my_chsize.c: Add functions SetFilePointerEx and SetEndOfFile for huge tables Move chsize to right place BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + include/config-win.h | 1 + mysys/my_chsize.c | 55 ++++++++++++++++++++++++++++------------ 3 files changed, 41 insertions(+), 16 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index be9d7b77650..a0a2edc0b96 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -109,6 +109,7 @@ vva@eagle.mysql.r18.ru vva@genie.(none) walrus@kishkin.ru walrus@mysql.com +wax@mysql.com worm@altair.is.lan zak@balfor.local zak@linux.local diff --git a/include/config-win.h b/include/config-win.h index 69020636893..cde77a6e0aa 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -276,6 +276,7 @@ inline double ulonglong2double(ulonglong value) #define HAVE_ISAM /* We want to have support for ISAM in 4.0 */ #define HAVE_QUERY_CACHE #define SPRINTF_RETURNS_INT +#define HAVE_SETFILEPOINTER /* SetFilePointer function for huge files */ #ifdef NOT_USED #define HAVE_SNPRINTF /* Gave link error */ diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index 06e8f159f4a..0840a7a69e4 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -36,24 +36,11 @@ 0 Ok 1 Error */ - int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { DBUG_ENTER("my_chsize"); DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength, MyFlags)); - -#ifdef HAVE_CHSIZE - if (chsize(fd,(off_t) newlength)) - { - DBUG_PRINT("error",("errno: %d",errno)); - my_errno=errno; - if (MyFlags & MY_WME) - my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); - DBUG_RETURN(1); - } - DBUG_RETURN(0); -#else /* if file is shorter, expand with null, else fill unused part with null */ { my_off_t oldsize; @@ -62,7 +49,42 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) oldsize = my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE)); DBUG_PRINT("info",("old_size: %ld", (ulong) oldsize)); -#ifdef HAVE_FTRUNCATE +#ifdef HAVE_CHSIZE + if (oldsize > newlength || filler == 0) + { + if (chsize(fd,(off_t) newlength)) + { + DBUG_PRINT("error",("errno: %d",errno)); + my_errno=errno; + if (MyFlags & MY_WME) + my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); + DBUG_RETURN(1); + } + else + { + if (filler == 0) + DBUG_RETURN(0); + } + } +#elif defined(HAVE_SETFILEPOINTER) + if (oldsize > newlength) + { + LARGE_INTEGER new_length; + HANDLE win_file; + win_file= (HANDLE)_get_osfhandle(fd); + new_length.QuadPart = newlength; + if (SetFilePointerEx(win_file,new_length,NULL,FILE_BEGIN)) + { + if (SetEndOfFile(win_file)) + DBUG_RETURN(0); + } + DBUG_PRINT("error",("errno: %d",errno)); + my_errno=errno; + if (MyFlags & MY_WME) + my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); + DBUG_RETURN(1); + } +#elif defined(HAVE_FTRUNCATE) if (oldsize > newlength) { if (ftruncate(fd, (off_t) newlength)) @@ -99,5 +121,6 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) DBUG_PRINT("error",("errno: %d",my_errno)); DBUG_RETURN(1); } -#endif -} /* my_chsize */ +} /* my_chsize */ + + From 2c3cba310aa401842996a52abdbde95bb950fcc5 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Jul 2003 15:47:00 +0400 Subject: [PATCH 012/282] merge commit sql-common/client.c: comment fix --- sql-common/client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-common/client.c b/sql-common/client.c index aac5be4b690..b43084855b9 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -1878,7 +1878,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, { /* By sending this very specific reply server asks us to send scrambled - password in old format. The reply contains scramble_323. + password in old format. */ scramble_323(buff, mysql->scramble, passwd); if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net)) From eb5f968c455276ba2d13e5b44edadef1294d5ab5 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 5 Aug 2003 21:14:15 +0200 Subject: [PATCH 013/282] table checksum background: my_checksum() mysys function NISAM checksum code moved from mysys to isam/ - it's obsolete MyISAM checksum code moved to mysys table's checksum accessible from sql layer SHOW TABLE STATUS shows checksum (WL#646) code cleanup include/my_sys.h: table checksum background: my_checksum() mysys function include/myisam.h: table checksum background: my_checksum() mysys function MyISAM checksum code moved to mysys isam/isamchk.c: table checksum background: NISAM checksum code moved from mysys to isam/ - it's obsolete isam/isamdef.h: table checksum background: NISAM checksum code moved from mysys to isam/ - it's obsolete isam/open.c: table checksum background: NISAM checksum code moved from mysys to isam/ - it's obsolete isam/pack_isam.c: table checksum background: NISAM checksum code moved from mysys to isam/ - it's obsolete myisam/mi_checksum.c: table checksum background: my_checksum() mysys function MyISAM checksum code moved to mysys mysys/checksum.c: table checksum background: my_checksum() mysys function MyISAM checksum code moved to mysys sql/ha_myisam.cc: table checksum background: table's checksum accessible from sql layer sql/ha_myisam.h: table checksum background: table's checksum accessible from sql layer sql/handler.h: table checksum background: table's checksum accessible from sql layer code cleanup sql/sql_lex.h: table checksum background: table's checksum accessible from sql layer code cleanup sql/sql_select.cc: warning removed sql/sql_show.cc: SHOW TABLE STATUS shows checksum (WL#646) sql/sql_yacc.yy: cleanup (DROP TABLES syntax added as a side effect :)) --- include/my_sys.h | 6 ++-- include/myisam.h | 2 -- isam/isamchk.c | 2 +- isam/isamdef.h | 1 + isam/open.c | 19 ++++++++++++ isam/pack_isam.c | 2 +- myisam/mi_checksum.c | 19 +++++------- mysys/checksum.c | 21 ++++++------- sql/ha_myisam.cc | 8 +++++ sql/ha_myisam.h | 1 + sql/handler.h | 71 ++++++++++++++++++++++---------------------- sql/sql_lex.h | 20 ++++++------- sql/sql_select.cc | 2 +- sql/sql_show.cc | 6 ++++ sql/sql_yacc.yy | 24 ++++++++------- 15 files changed, 119 insertions(+), 85 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index e4125a2e7e6..6721d77a8af 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -213,7 +213,7 @@ extern uint get_charset_number(const char *cs_name); extern const char *get_charset_name(uint cs_number); extern CHARSET_INFO *get_charset(uint cs_number, myf flags); extern CHARSET_INFO *get_charset_by_name(const char *cs_name, myf flags); -extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, +extern CHARSET_INFO *get_charset_by_csname(const char *cs_name, uint cs_flags, myf my_flags); extern void free_charsets(void); extern char *get_charsets_dir(char *buf); @@ -507,6 +507,8 @@ typedef struct st_keycache ulonglong size; } KEY_CACHE; +typedef uint32 ha_checksum; + #include /* Prototypes for mysys and my_func functions */ @@ -749,7 +751,7 @@ extern void print_defaults(const char *conf_file, const char **groups); extern my_bool my_compress(byte *, ulong *, ulong *); extern my_bool my_uncompress(byte *, ulong *, ulong *); extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); -extern ulong checksum(const byte *mem, uint count); +extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); extern uint my_bit_log2(ulong value); uint my_count_bits(ulonglong v); extern void my_sleep(ulong m_seconds); diff --git a/include/myisam.h b/include/myisam.h index e85d3057672..0ffcdae8567 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -53,8 +53,6 @@ extern "C" { #define mi_portable_sizeof_char_ptr 8 -typedef uint32 ha_checksum; - /* Param to/from mi_info */ typedef struct st_mi_isaminfo /* Struct from h_info */ diff --git a/isam/isamchk.c b/isam/isamchk.c index dc772290e13..939a4be732f 100644 --- a/isam/isamchk.c +++ b/isam/isamchk.c @@ -1328,7 +1328,7 @@ int extend; print_error("Found wrong record at %lu",(ulong) start_recpos); got_error=1; } - crc^=checksum(record,info->s->base.reclength); + crc^=_nisam_checksum(record,info->s->base.reclength); link_used+=info->s->pack.ref_length; used+=block_info.rec_len+info->s->pack.ref_length; } diff --git a/isam/isamdef.h b/isam/isamdef.h index 0884b18e997..54656b6842e 100644 --- a/isam/isamdef.h +++ b/isam/isamdef.h @@ -358,6 +358,7 @@ extern int _nisam_read_pack_record(N_INFO *info,ulong filepos,byte *buf); extern int _nisam_read_rnd_pack_record(N_INFO*, byte *,ulong, int); extern int _nisam_pack_rec_unpack(N_INFO *info,byte *to,byte *from, uint reclength); +extern ulong _nisam_checksum(const byte *mem, uint count); typedef struct st_sortinfo { uint key_length; diff --git a/isam/open.c b/isam/open.c index 48fab27cac1..824fbe804ee 100644 --- a/isam/open.c +++ b/isam/open.c @@ -453,3 +453,22 @@ static void setup_key_functions(register N_KEYDEF *keyinfo) } return; } + +/* + Calculate a long checksum for a memoryblock. Used to verify pack_isam + + SYNOPSIS + checksum() + mem Pointer to memory block + count Count of bytes +*/ + +ulong _nisam_checksum(const byte *mem, uint count) +{ + ulong crc; + for (crc= 0; count-- ; mem++) + crc= ((crc << 1) + *((uchar*) mem)) + + test(crc & ((ulong) 1L << (8*sizeof(ulong)-1))); + return crc; +} + diff --git a/isam/pack_isam.c b/isam/pack_isam.c index fd12aac1e09..9108070f918 100644 --- a/isam/pack_isam.c +++ b/isam/pack_isam.c @@ -738,7 +738,7 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts) { if (! error) { - crc^=checksum(record,reclength); + crc^=_nisam_checksum(record,reclength); for (pos=record,count=huff_counts ; count < end_count ; count++, diff --git a/myisam/mi_checksum.c b/myisam/mi_checksum.c index a760b03a032..982f77ee81f 100644 --- a/myisam/mi_checksum.c +++ b/myisam/mi_checksum.c @@ -28,30 +28,29 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf) { const byte *pos; const byte *end; + ulong length; switch (rec->type) { case FIELD_BLOB: { - ulong length=_mi_calc_blob_length(rec->length- + length=_mi_calc_blob_length(rec->length- mi_portable_sizeof_char_ptr, buf); memcpy((char*) &pos, buf+rec->length- mi_portable_sizeof_char_ptr, sizeof(char*)); - end=pos+length; break; } case FIELD_VARCHAR: { - uint length; length=uint2korr(buf); - pos=buf+2; end=pos+length; + pos=buf+2; break; } default: - pos=buf; end=buf+rec->length; + length=rec->length; + pos=buf; break; } - for ( ; pos != end ; pos++) - crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8)); + crc=my_checksum(crc, pos, length); } return crc; } @@ -59,9 +58,5 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf) ha_checksum mi_static_checksum(MI_INFO *info, const byte *pos) { - ha_checksum crc; - const byte *end=pos+info->s->base.reclength; - for (crc=0; pos != end; pos++) - crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8)); - return crc; + return my_checksum(0, pos, info->s->base.reclength); } diff --git a/mysys/checksum.c b/mysys/checksum.c index 1dd135c7ad9..2ae139b81c3 100644 --- a/mysys/checksum.c +++ b/mysys/checksum.c @@ -19,19 +19,20 @@ #include "my_sys.h" /* - Calculate a long checksum for a memoryblock. Used to verify pack_isam - + Calculate a long checksum for a memoryblock. + SYNOPSIS - checksum() - mem Pointer to memory block - count Count of bytes + my_checksum() + crc start value for crc + pos pointer to memory block + length length of the block */ -ulong checksum(const byte *mem, uint count) +ha_checksum my_checksum(ha_checksum crc, const byte *pos, uint length) { - ulong crc; - for (crc= 0; count-- ; mem++) - crc= ((crc << 1) + *((uchar*) mem)) + - test(crc & ((ulong) 1L << (8*sizeof(ulong)-1))); + const byte *end=pos+length; + for ( ; pos != end ; pos++) + crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8)); return crc; } + diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 4f1021232a4..d2cbdec36f1 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -236,6 +236,8 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) VOID(mi_extra(file, HA_EXTRA_WAIT_LOCK, 0)); if (!table->db_record_offset) int_table_flags|=HA_REC_NOT_IN_SEQ; + if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) + int_table_flags|=HA_HAS_CHECKSUM; return (0); } @@ -1398,3 +1400,9 @@ int ha_myisam::ft_read(byte * buf) table->status=error ? STATUS_NOT_FOUND: 0; return error; } + +uint ha_myisam::checksum() const +{ + return (uint)file->s->state.checksum; +} + diff --git a/sql/ha_myisam.h b/sql/ha_myisam.h index 8486e25556b..e4e3192af10 100644 --- a/sql/ha_myisam.h +++ b/sql/ha_myisam.h @@ -64,6 +64,7 @@ class ha_myisam: public handler uint max_keys() const { return MI_MAX_KEY; } uint max_key_parts() const { return MAX_REF_PARTS; } uint max_key_length() const { return MI_MAX_KEY_LENGTH; } + uint checksum() const; int open(const char *name, int mode, uint test_if_locked); int close(void); diff --git a/sql/handler.h b/sql/handler.h index 08a7c83d328..c26efa47ded 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -42,38 +42,39 @@ #define HA_ADMIN_INVALID -5 /* Bits in table_flags() to show what database can do */ -#define HA_READ_RND_SAME 1 /* Read RND-record to KEY-record - (To update with RND-read) */ -#define HA_KEYPOS_TO_RNDPOS 2 /* ha_info gives pos to record */ -#define HA_TABLE_SCAN_ON_INDEX 4 /* No separate data/index file */ -#define HA_REC_NOT_IN_SEQ 8 /* ha_info don't return recnumber; - It returns a position to ha_r_rnd */ -#define HA_HAS_GEOMETRY 16 -#define HA_NO_INDEX 32 /* No index needed for next/prev */ -#define HA_KEY_READ_WRONG_STR 64 /* keyread returns converted strings */ -#define HA_NULL_KEY 128 /* One can have keys with NULL */ -#define HA_DUPP_POS 256 /* ha_position() gives dupp row */ -#define HA_NO_BLOBS 512 /* Doesn't support blobs */ -#define HA_BLOB_KEY (HA_NO_BLOBS*2) /* key on blob */ -#define HA_AUTO_PART_KEY (HA_BLOB_KEY*2) -#define HA_REQUIRE_PRIMARY_KEY (HA_AUTO_PART_KEY*2) -#define HA_NOT_EXACT_COUNT (HA_REQUIRE_PRIMARY_KEY*2) -#define HA_NO_WRITE_DELAYED (HA_NOT_EXACT_COUNT*2) -#define HA_PRIMARY_KEY_IN_READ_INDEX (HA_NO_WRITE_DELAYED*2) -#define HA_DROP_BEFORE_CREATE (HA_PRIMARY_KEY_IN_READ_INDEX*2) -#define HA_NOT_READ_AFTER_KEY (HA_DROP_BEFORE_CREATE*2) -#define HA_NOT_DELETE_WITH_CACHE (HA_NOT_READ_AFTER_KEY*2) -#define HA_NO_TEMP_TABLES (HA_NOT_DELETE_WITH_CACHE*2) -#define HA_NO_PREFIX_CHAR_KEYS (HA_NO_TEMP_TABLES*2) -#define HA_CAN_FULLTEXT (HA_NO_PREFIX_CHAR_KEYS*2) -#define HA_CAN_SQL_HANDLER (HA_CAN_FULLTEXT*2) -#define HA_NO_AUTO_INCREMENT (HA_CAN_SQL_HANDLER*2) +#define HA_READ_RND_SAME 1 /* Read RND-record to KEY-record + (To update with RND-read) */ +#define HA_KEYPOS_TO_RNDPOS 2 /* ha_info gives pos to record */ +#define HA_TABLE_SCAN_ON_INDEX 4 /* No separate data/index file */ +#define HA_REC_NOT_IN_SEQ 8 /* ha_info don't return recnumber; + It returns a position to ha_r_rnd */ +#define HA_HAS_GEOMETRY (1 << 4) +#define HA_NO_INDEX (1 << 5) /* No index needed for next/prev */ +#define HA_KEY_READ_WRONG_STR (1 << 6) /* keyread returns converted strings */ +#define HA_NULL_KEY (1 << 7) /* One can have keys with NULL */ +#define HA_DUPP_POS (1 << 8) /* ha_position() gives dupp row */ +#define HA_NO_BLOBS (1 << 9) /* Doesn't support blobs */ +#define HA_BLOB_KEY (1 << 10) /* key on blob */ +#define HA_AUTO_PART_KEY (1 << 11) +#define HA_REQUIRE_PRIMARY_KEY (1 << 12) +#define HA_NOT_EXACT_COUNT (1 << 13) +#define HA_NO_WRITE_DELAYED (1 << 14) +#define HA_PRIMARY_KEY_IN_READ_INDEX (1 << 15) +#define HA_DROP_BEFORE_CREATE (1 << 16) +#define HA_NOT_READ_AFTER_KEY (1 << 17) +#define HA_NOT_DELETE_WITH_CACHE (1 << 18) +#define HA_NO_TEMP_TABLES (1 << 19) +#define HA_NO_PREFIX_CHAR_KEYS (1 << 20) +#define HA_CAN_FULLTEXT (1 << 21) +#define HA_CAN_SQL_HANDLER (1 << 22) +#define HA_NO_AUTO_INCREMENT (1 << 23) +#define HA_HAS_CHECKSUM (1 << 24) /* Next record gives next record according last record read (even if database is updated after read). Not used at this point. */ -#define HA_LASTKEY_ORDER (HA_NO_AUTO_INCREMENT*2) +#define HA_LASTKEY_ORDER (1 << 25) /* bits in index_flags(index_number) for what you can do with index */ @@ -304,8 +305,8 @@ public: virtual bool check_and_repair(THD *thd) {return 1;} virtual int optimize(THD* thd,HA_CHECK_OPT* check_opt); virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt); - virtual int backup(THD* thd, HA_CHECK_OPT* check_opt); virtual int preload_keys(THD* thd, HA_CHECK_OPT* check_opt); + virtual int backup(THD* thd, HA_CHECK_OPT* check_opt); /* restore assumes .frm file must exist, and that generate_table() has been called; It will just copy the data file and run repair. @@ -323,8 +324,8 @@ public: virtual char* get_foreign_key_create_info() { return(NULL);} /* gets foreign key create string from InnoDB */ virtual void init_table_handle_for_HANDLER() - { return; } /* prepare InnoDB for HANDLER */ - virtual void free_foreign_key_create_info(char* str) {} + { return; } /* prepare InnoDB for HANDLER */ + virtual void free_foreign_key_create_info(char* str) {} /* The following can be called without an open handler */ virtual const char *table_type() const =0; virtual const char **bas_ext() const =0; @@ -340,6 +341,7 @@ public: virtual uint max_key_part_length() { return 255; } virtual uint min_record_length(uint options) const { return 1; } virtual bool low_byte_first() const { return 1; } + virtual uint checksum() const { return 0; } virtual bool is_crashed() const { return 0; } virtual bool auto_repair() const { return 0; } @@ -353,13 +355,12 @@ public: /* Type of table for caching query */ virtual uint8 table_cache_type() { return HA_CACHE_TBL_NONTRANSACT; } - /* - Is query with this cable cachable (have sense only for ASKTRANSACT + /* + Is query with this table cachable (have sense only for ASKTRANSACT tables) */ - static bool caching_allowed(THD* thd, char* table_key, + static bool caching_allowed(THD* thd, char* table_key, uint key_length, uint8 cahe_type); - }; /* Some extern variables used with handlers */ @@ -388,7 +389,7 @@ int ha_delete_table(enum db_type db_type, const char *path); void ha_drop_database(char* path); void ha_key_cache(void); void ha_resize_key_cache(void); -int ha_start_stmt(THD *thd); +int ha_start_stmt(THD *thd); int ha_report_binlog_offset_and_commit(THD *thd, char *log_file_name, my_off_t end_offset); int ha_commit_complete(THD *thd); diff --git a/sql/sql_lex.h b/sql/sql_lex.h index faf7e16e54a..df73f12d32f 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -447,15 +447,21 @@ typedef struct st_lex SELECT_LEX *all_selects_list; uchar *ptr,*tok_start,*tok_end,*end_of_query; char *length,*dec,*change,*name; + char *help_arg; char *backup_dir; /* For RESTORE/BACKUP */ char* to_log; /* For PURGE MASTER LOGS TO */ time_t purge_time; /* For PURGE MASTER LOGS BEFORE */ char* x509_subject,*x509_issuer,*ssl_cipher; char* found_colon; /* For multi queries - next query */ - enum SSL_type ssl_type; /* defined in violite.h */ String *wild; sql_exchange *exchange; select_result *result; + Item *default_value, *comment; + LEX_USER *grant_user; + gptr yacc_yyss,yacc_yyvs; + THD *thd; + CHARSET_INFO *charset; + SQL_LIST *gorder_list; List col_list; List ref_list; @@ -473,11 +479,6 @@ typedef struct st_lex SQL_LIST proc_list, auxilliary_table_list; TYPELIB *interval; create_field *last_field; - Item *default_value, *comment; - uint uint_geom_type; - LEX_USER *grant_user; - gptr yacc_yyss,yacc_yyvs; - THD *thd; udf_func udf; HA_CHECK_OPT check_opt; // check/repair options HA_CREATE_INFO create_info; @@ -486,6 +487,7 @@ typedef struct st_lex ulong thread_id,type; enum_sql_command sql_command; thr_lock_type lock_option; + enum SSL_type ssl_type; /* defined in violite.h */ enum my_lex_states next_state; enum enum_duplicates duplicates; enum enum_tx_isolation tx_isolation; @@ -493,17 +495,15 @@ typedef struct st_lex enum ha_rkey_function ha_rkey_mode; enum enum_enable_or_disable alter_keys_onoff; enum enum_var_type option_type; + uint uint_geom_type; uint grant, grant_tot_col, which_columns; uint fk_delete_opt, fk_update_opt, fk_match_option; uint param_count; + uint slave_thd_opt; bool drop_primary, drop_if_exists, drop_temporary, local_file; bool in_comment, ignore_space, verbose, simple_alter, no_write_to_binlog; bool derived_tables, describe; bool safe_to_cache_query; - uint slave_thd_opt; - CHARSET_INFO *charset; - char *help_arg; - SQL_LIST *gorder_list; st_lex() {} inline void uncacheable() { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 0aa7e67a12b..12d93dfc674 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2349,7 +2349,7 @@ static void optimize_keyuse(JOIN *join, DYNAMIC_ARRAY *keyuse_array) Constant tables are ignored. To avoid bad matches, we don't make ref_table_rows less than 100. */ - keyuse->ref_table_rows= ~(table_map) 0; // If no ref + keyuse->ref_table_rows= ~(ha_rows) 0; // If no ref if (keyuse->used_tables & (map= (keyuse->used_tables & ~join->const_table_map & ~OUTER_REF_TABLE_BIT))) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 9084269f486..7dd2004b664 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -503,6 +503,8 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) item->maybe_null=1; field_list.push_back(item=new Item_empty_string("Charset",32)); item->maybe_null=1; + field_list.push_back(item=new Item_int("Checksum",(longlong) 1,21)); + item->maybe_null=1; field_list.push_back(item=new Item_empty_string("Create_options",255)); item->maybe_null=1; field_list.push_back(item=new Item_empty_string("Comment",80)); @@ -588,6 +590,10 @@ int mysqld_extend_show_tables(THD *thd,const char *db,const char *wild) } str= (table->table_charset ? table->table_charset->name : "default"); protocol->store(str, system_charset_info); + if (file->table_flags() & HA_HAS_CHECKSUM) + protocol->store((ulonglong)file->checksum()); + else + protocol->store_null(); // Checksum { char option_buff[350],*ptr; ptr=option_buff; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index a5ac04dc775..2e8ed389a98 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -730,17 +730,19 @@ verb_clause: | describe | do | drop - | grant - | insert | flush + | grant + | handler + | help + | insert + | kill | load | lock - | kill | optimize | preload | purge | rename - | repair + | repair | replace | reset | restore @@ -748,15 +750,14 @@ verb_clause: | rollback | select | set + | show | slave | start - | show | truncate - | handler | unlock | update | use - | help; + ; /* help */ @@ -1817,7 +1818,7 @@ optimize: { LEX *lex=Lex; lex->sql_command = SQLCOM_OPTIMIZE; - lex->no_write_to_binlog= $2; + lex->no_write_to_binlog= $2; lex->check_opt.init(); } table_list opt_mi_check_type @@ -3327,7 +3328,7 @@ do: DO_SYM */ drop: - DROP opt_temporary TABLE_SYM if_exists table_list opt_restrict + DROP opt_temporary table_or_tables if_exists table_list opt_restrict { LEX *lex=Lex; lex->sql_command = SQLCOM_DROP_TABLE; @@ -3363,7 +3364,7 @@ drop: LEX *lex=Lex; lex->sql_command = SQLCOM_DROP_USER; lex->users_list.empty(); - } + } user_list {} ; @@ -4851,7 +4852,7 @@ grant_privilege_list: | grant_privilege_list ',' grant_privilege; grant_privilege: - SELECT_SYM { Lex->which_columns = SELECT_ACL;} opt_column_list {} + SELECT_SYM { Lex->which_columns = SELECT_ACL;} opt_column_list {} | INSERT { Lex->which_columns = INSERT_ACL;} opt_column_list {} | UPDATE_SYM { Lex->which_columns = UPDATE_ACL; } opt_column_list {} | REFERENCES { Lex->which_columns = REFERENCES_ACL;} opt_column_list {} @@ -5228,3 +5229,4 @@ subselect_end: LEX *lex=Lex; lex->current_select = lex->current_select->return_after_parsing(); }; + From 5f016696ec7ef7c5ee43943e66d3483ea55f6041 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 7 Aug 2003 15:20:15 +0200 Subject: [PATCH 014/282] openssl_1.result, openssl_1.test: Aligned test with regenerated SSL certs Many files: Regenerated expired certificates SSL/cacert.pem: Regenerated expired certificates SSL/client-cert.pem: Regenerated expired certificates SSL/client-key.pem: Regenerated expired certificates SSL/client-req.pem: Regenerated expired certificates SSL/server-cert.pem: Regenerated expired certificates SSL/server-key.pem: Regenerated expired certificates SSL/server-req.pem: Regenerated expired certificates mysql-test/t/openssl_1.test: Aligned test with regenerated SSL certs mysql-test/r/openssl_1.result: Aligned test with regenerated SSL certs BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + SSL/cacert.pem | 37 +++++++-------- SSL/client-cert.pem | 87 ++++++++++++++++++----------------- SSL/client-key.pem | 26 +++++------ SSL/client-req.pem | 38 ++++----------- SSL/server-cert.pem | 86 +++++++++++++++++----------------- SSL/server-key.pem | 26 +++++------ SSL/server-req.pem | 38 ++++----------- mysql-test/r/openssl_1.result | 4 +- mysql-test/t/openssl_1.test | 4 +- 10 files changed, 158 insertions(+), 189 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index edb3f4141da..ccc94722e41 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -15,6 +15,7 @@ bell@laptop.sanja.is.com.ua bell@sanja.is.com.ua bk@admin.bk davida@isil.mysql.com +dlenev@build.mysql.com dlenev@mysql.com gluh@gluh.(none) gluh@gluh.mysql.r18.ru diff --git a/SSL/cacert.pem b/SSL/cacert.pem index 698784b49f9..b939a037c30 100644 --- a/SSL/cacert.pem +++ b/SSL/cacert.pem @@ -1,20 +1,21 @@ -----BEGIN CERTIFICATE----- -MIIDQjCCAqugAwIBAgIBADANBgkqhkiG9w0BAQQFADB6MQswCQYDVQQGEwJSVTET -MBEGA1UECBMKU29tZS1TdGF0ZTERMA8GA1UEBxMIT3JlbmJ1cmcxETAPBgNVBAoT -CE15U1FMIEFCMQ8wDQYDVQQDEwZXYWxydXMxHzAdBgkqhkiG9w0BCQEWEHdhbHJ1 -c0BteXNxbC5jb20wHhcNMDIwODAyMjE1NTUzWhcNMDMwODAyMjE1NTUzWjB6MQsw -CQYDVQQGEwJSVTETMBEGA1UECBMKU29tZS1TdGF0ZTERMA8GA1UEBxMIT3JlbmJ1 -cmcxETAPBgNVBAoTCE15U1FMIEFCMQ8wDQYDVQQDEwZXYWxydXMxHzAdBgkqhkiG -9w0BCQEWEHdhbHJ1c0BteXNxbC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJ -AoGBALFLPDNDeq213XvhBP3TxhC0NcGKJ/sWzaHkNmunQ8sTbV8AfdFafvP7cSHk -O3jh7smpVWnxmcIbq1dpsbb7X5vQVc8ru07Z8VhCJWx6H8kgI95Am6wbm2ho2Lok -9ODG8f/lA4kLv8Vo0hqtfV5T1mnZpSzkh6G4b0yPzHu8gtObAgMBAAGjgdcwgdQw -HQYDVR0OBBYEFNnYan2rzhBiGhb86Wr03PFmrNC5MIGkBgNVHSMEgZwwgZmAFNnY -an2rzhBiGhb86Wr03PFmrNC5oX6kfDB6MQswCQYDVQQGEwJSVTETMBEGA1UECBMK -U29tZS1TdGF0ZTERMA8GA1UEBxMIT3JlbmJ1cmcxETAPBgNVBAoTCE15U1FMIEFC -MQ8wDQYDVQQDEwZXYWxydXMxHzAdBgkqhkiG9w0BCQEWEHdhbHJ1c0BteXNxbC5j -b22CAQAwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQADeMZEA5Rh4PDq -DmS9cYyogjb9gkuLHeo/pqfU8iSZVsSaf6Uqh6TWKQOuK3I4R1K8iMo4cW6LhxxH -HLFrVIQn6xhLvfC0T6Zl7G0w6rAY2+QlbEhjnsgHtLGrB5xjSYLq6Uz3gAMbEsA4 -rCpQJECDe2PzoUXZj9mE2sdljiGcvQ== +MIIDcTCCAtqgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCU0Ux +EDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhB +YnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0 +Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wHhcNMDMwODA3MTEyMTQwWhcNMDMw +OTA2MTEyMTQwWjCBiDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAP +BgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhBYnN0cmFjdCBNeVNRTCBEZXZlbG9w +ZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNx +bC5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALgbnH12rP8XEJsRuy69 +9n412tEOucpQyxkpNiDgLRvlYEGIJutK2LAqPHoPg7Em2+WJ+vrFh/BVx4hOUHmk +tJ94qTHLLCCj07cjzcoADjzPT9254VqSuQy/JvDNamKEOEdXU8l4/bc26VKVZ99x +iqXbHLiIWNa+UUwyRDSkERepAgMBAAGjgegwgeUwHQYDVR0OBBYEFJVKQT7xXBK0 +ez6fOwwjZpA9f07YMIG1BgNVHSMEga0wgaqAFJVKQT7xXBK0ez6fOwwjZpA9f07Y +oYGOpIGLMIGIMQswCQYDVQQGEwJTRTEQMA4GA1UEBxMHVXBwc2FsYTERMA8GA1UE +ChMITXlTUUwgQUIxITAfBgNVBAMTGEFic3RyYWN0IE15U1FMIERldmVsb3BlcjEx +MC8GCSqGSIb3DQEJARYiYWJzdHJhY3QubXlzcWwuZGV2ZWxvcGVyQG15c3FsLmNv +bYIBADAMBgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBBAUAA4GBAJFucCIj0wREcF9P +vOaKVbvcaBwgit6oXOf7ZOPcIUQxQJOnXLVkWIdMP2mP/zHAUsCmXT2k8aXWRegB +6kh/PjV/vSYFbGtE/vh/12x/nSIUU+Y9B1EwvoeskuOwu34Ih514Y1z1bPMNt18N +4LGzMEBeklJ3gxBPlRXER9BSUpRH -----END CERTIFICATE----- diff --git a/SSL/client-cert.pem b/SSL/client-cert.pem index 729379babdc..54b173baae2 100644 --- a/SSL/client-cert.pem +++ b/SSL/client-cert.pem @@ -3,24 +3,24 @@ Certificate: Version: 3 (0x2) Serial Number: 2 (0x2) Signature Algorithm: md5WithRSAEncryption - Issuer: C=RU, ST=Some-State, L=Orenburg, O=MySQL AB, CN=Walrus/Email=walrus@mysql.com + Issuer: C=SE, L=Uppsala, O=MySQL AB, CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com Validity - Not Before: Aug 2 22:08:07 2002 GMT - Not After : Aug 2 22:08:07 2003 GMT - Subject: C=RU, L=orenburg, O=MySQL AB, OU=client, CN=walrus/Email=walrus@mysql.com + Not Before: Aug 7 11:41:56 2003 GMT + Not After : Aug 4 11:41:56 2013 GMT + Subject: C=SE, L=Uppsala, O=MySQL AB, CN=MySQL Client/Email=abstract.mysql.developer@mysql.com Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Modulus (1024 bit): - 00:ab:27:e4:1e:f0:34:8b:a9:50:df:0a:b0:55:20: - b3:1f:0f:cf:f1:51:1e:66:48:a6:f8:4e:0d:d4:49: - f4:ea:d3:41:6b:7e:06:78:3c:29:9d:8e:d3:33:4d: - 0b:fc:34:4d:18:88:48:61:af:11:da:db:84:c0:92: - 91:81:6a:b6:21:d5:8e:9b:f2:6f:d8:06:ad:d6:77: - f6:8b:bd:07:d5:b7:fb:c6:f0:64:e6:3f:58:f0:6a: - 1e:81:73:97:6d:9d:c6:ec:b0:5e:1e:c6:57:82:b0: - 98:9c:ae:26:84:43:0d:98:6c:b4:d8:52:13:70:15: - 79:61:40:84:19:ea:f6:63:3f + 00:c4:03:0a:ee:e3:b1:12:fc:ee:b4:19:f4:e1:60: + 1d:e0:28:c3:96:2d:df:82:69:cd:74:7c:54:58:d0: + ae:b3:59:3f:0c:19:1c:99:10:a6:12:c9:cf:3a:64: + 05:43:8e:bf:d2:65:36:80:91:0b:65:b0:27:26:38: + c9:23:d8:36:a2:4a:f0:f7:c0:2f:68:38:70:01:27: + 29:ff:b2:c5:52:e1:6b:f1:c8:d7:c3:5c:ee:f0:37: + 6c:2a:9b:96:1a:05:9e:eb:33:a2:39:5a:77:66:62: + 27:75:1f:2f:6f:38:da:e5:9f:78:af:ca:6b:22:3f: + 57:2b:bc:a6:8f:47:d1:99:6f Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: @@ -28,39 +28,40 @@ Certificate: Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: - A6:D9:70:92:AC:2B:F6:48:A5:FB:29:CF:78:4A:57:B5:3B:43:97:EE + 80:81:A9:22:EB:AB:D6:CA:7E:3F:8D:BB:D1:AC:2A:F4:87:9D:13:29 X509v3 Authority Key Identifier: - keyid:D9:D8:6A:7D:AB:CE:10:62:1A:16:FC:E9:6A:F4:DC:F1:66:AC:D0:B9 - DirName:/C=RU/ST=Some-State/L=Orenburg/O=MySQL AB/CN=Walrus/Email=walrus@mysql.com + keyid:95:4A:41:3E:F1:5C:12:B4:7B:3E:9F:3B:0C:23:66:90:3D:7F:4E:D8 + DirName:/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com serial:00 Signature Algorithm: md5WithRSAEncryption - 15:96:43:10:89:e0:a6:82:a4:91:0f:7e:2e:d8:80:54:ba:63: - e2:8f:b0:aa:ea:be:35:2c:8f:0d:03:a9:86:2e:32:51:33:8a: - cc:b2:5e:b3:12:cb:b7:42:06:40:89:ce:92:87:40:f1:6a:79: - 0c:3e:00:1d:06:bf:3c:c1:da:f6:3b:e1:42:e6:55:4c:31:e1: - b9:79:f3:99:14:f6:68:9e:67:2b:e3:71:88:6b:2b:e2:08:bd: - 67:79:ea:0e:7d:34:0d:41:22:3a:f4:8f:4d:51:07:6f:5a:44: - 34:05:d1:b3:ca:cf:09:2b:43:25:a1:7f:ac:f4:54:f1:e3:93: - 47:44 + 6d:8a:af:34:07:ac:95:72:a4:78:fe:f8:b8:30:9a:e0:d9:74: + 82:34:5c:fd:11:15:dd:63:fd:65:20:04:7e:b5:8f:2e:26:ef: + ab:b9:10:5f:9b:40:65:76:ab:ed:bd:bf:d5:bc:89:7f:19:d8: + a7:b5:9e:24:bd:c7:ac:8e:16:35:83:c8:ce:8d:85:7c:b4:36: + 28:dd:3a:97:e5:b2:dd:8f:88:4d:5b:50:bd:97:28:61:8e:e7: + 05:5c:c2:bb:46:a1:ac:7e:ee:ac:7d:72:d5:a7:07:4e:1d:68: + 4e:80:e2:35:7d:db:24:73:be:bc:0d:ca:f4:ae:4e:21:52:3b: + ae:81 -----BEGIN CERTIFICATE----- -MIIDajCCAtOgAwIBAgIBAjANBgkqhkiG9w0BAQQFADB6MQswCQYDVQQGEwJSVTET -MBEGA1UECBMKU29tZS1TdGF0ZTERMA8GA1UEBxMIT3JlbmJ1cmcxETAPBgNVBAoT -CE15U1FMIEFCMQ8wDQYDVQQDEwZXYWxydXMxHzAdBgkqhkiG9w0BCQEWEHdhbHJ1 -c0BteXNxbC5jb20wHhcNMDIwODAyMjIwODA3WhcNMDMwODAyMjIwODA3WjB2MQsw -CQYDVQQGEwJSVTERMA8GA1UEBxMIb3JlbmJ1cmcxETAPBgNVBAoTCE15U1FMIEFC -MQ8wDQYDVQQLEwZjbGllbnQxDzANBgNVBAMTBndhbHJ1czEfMB0GCSqGSIb3DQEJ -ARYQd2FscnVzQG15c3FsLmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA -qyfkHvA0i6lQ3wqwVSCzHw/P8VEeZkim+E4N1En06tNBa34GeDwpnY7TM00L/DRN -GIhIYa8R2tuEwJKRgWq2IdWOm/Jv2Aat1nf2i70H1bf7xvBk5j9Y8GoegXOXbZ3G -7LBeHsZXgrCYnK4mhEMNmGy02FITcBV5YUCEGer2Yz8CAwEAAaOCAQIwgf8wCQYD -VR0TBAIwADAsBglghkgBhvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlm -aWNhdGUwHQYDVR0OBBYEFKbZcJKsK/ZIpfspz3hKV7U7Q5fuMIGkBgNVHSMEgZww -gZmAFNnYan2rzhBiGhb86Wr03PFmrNC5oX6kfDB6MQswCQYDVQQGEwJSVTETMBEG -A1UECBMKU29tZS1TdGF0ZTERMA8GA1UEBxMIT3JlbmJ1cmcxETAPBgNVBAoTCE15 -U1FMIEFCMQ8wDQYDVQQDEwZXYWxydXMxHzAdBgkqhkiG9w0BCQEWEHdhbHJ1c0Bt -eXNxbC5jb22CAQAwDQYJKoZIhvcNAQEEBQADgYEAFZZDEIngpoKkkQ9+LtiAVLpj -4o+wquq+NSyPDQOphi4yUTOKzLJesxLLt0IGQInOkodA8Wp5DD4AHQa/PMHa9jvh -QuZVTDHhuXnzmRT2aJ5nK+NxiGsr4gi9Z3nqDn00DUEiOvSPTVEHb1pENAXRs8rP -CStDJaF/rPRU8eOTR0Q= +MIIDkTCCAvqgAwIBAgIBAjANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCU0Ux +EDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhB +YnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0 +Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wHhcNMDMwODA3MTE0MTU2WhcNMTMw +ODA0MTE0MTU2WjB8MQswCQYDVQQGEwJTRTEQMA4GA1UEBxMHVXBwc2FsYTERMA8G +A1UEChMITXlTUUwgQUIxFTATBgNVBAMTDE15U1FMIENsaWVudDExMC8GCSqGSIb3 +DQEJARYiYWJzdHJhY3QubXlzcWwuZGV2ZWxvcGVyQG15c3FsLmNvbTCBnzANBgkq +hkiG9w0BAQEFAAOBjQAwgYkCgYEAxAMK7uOxEvzutBn04WAd4CjDli3fgmnNdHxU +WNCus1k/DBkcmRCmEsnPOmQFQ46/0mU2gJELZbAnJjjJI9g2okrw98AvaDhwAScp +/7LFUuFr8cjXw1zu8DdsKpuWGgWe6zOiOVp3ZmIndR8vbzja5Z94r8prIj9XK7ym +j0fRmW8CAwEAAaOCARQwggEQMAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9w +ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBSAgaki66vWyn4/ +jbvRrCr0h50TKTCBtQYDVR0jBIGtMIGqgBSVSkE+8VwStHs+nzsMI2aQPX9O2KGB +jqSBizCBiDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoT +CE15U1FMIEFCMSEwHwYDVQQDExhBYnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAv +BgkqhkiG9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb22C +AQAwDQYJKoZIhvcNAQEEBQADgYEAbYqvNAeslXKkeP74uDCa4Nl0gjRc/REV3WP9 +ZSAEfrWPLibvq7kQX5tAZXar7b2/1byJfxnYp7WeJL3HrI4WNYPIzo2FfLQ2KN06 +l+Wy3Y+ITVtQvZcoYY7nBVzCu0ahrH7urH1y1acHTh1oToDiNX3bJHO+vA3K9K5O +IVI7roE= -----END CERTIFICATE----- diff --git a/SSL/client-key.pem b/SSL/client-key.pem index feff11bfdb7..58fa805e620 100644 --- a/SSL/client-key.pem +++ b/SSL/client-key.pem @@ -1,15 +1,15 @@ -----BEGIN RSA PRIVATE KEY----- -MIICXQIBAAKBgQCrJ+Qe8DSLqVDfCrBVILMfD8/xUR5mSKb4Tg3USfTq00FrfgZ4 -PCmdjtMzTQv8NE0YiEhhrxHa24TAkpGBarYh1Y6b8m/YBq3Wd/aLvQfVt/vG8GTm -P1jwah6Bc5dtncbssF4exleCsJicriaEQw2YbLTYUhNwFXlhQIQZ6vZjPwIDAQAB -AoGAChyxPaKzeAzo2kSnZmAoNQ2aG4fPY/um4cS6zHASKE2S7+biOvhS/RwTHlTP -AHeWlnx2yk6tn2CY10fRkPPdDsnyj7FpuZmjhmFtprOn+1Mwft7gNTMdKN2EV46/ -hMQxm8/Wu9ejm6IhOeg3Q7lBFwE9tY0kgMzU4zDI3A0HDQECQQDUcxFgxIrOi4Gw -EGxmJgopL+NjG7/4PdT2FM5z1bbwOtfsD1fHKWSiODbfpK8eMwBReI4wfDQ7ViND -xmuDykFDAkEAzj3QH9s8Ej3Vgt88326OhY1W5jTH6M0XkuZ0YatELz3MvLwFhIF4 -puouLJQVo3pQBLV+Tmnh2LQqkii7xA7oVQJBALZxzvW0M6QmyAvEPuMGPema94KQ -PS7ZIr7lpVpyqTTqw600i+Q8VvC8p9stmTmtANP2XN2kfFKMqaI1jvVRxvMCQDJE -8sOxBjVUCQS7MPUs12RKDRJTbx6ZTtOphFiCDD6Pi6W9FoMzo5rbnaGT/qo4F+Tt -7/lg6YGOeInjj9C76XkCQQC2m6j8NeX9E4Pimp1GDE93N2JJ+biJxLI8yFqruv7N -B2M/28JKLGLjam6YVJy4eSA9clXVqwWNxii3fb8qQ7u6 +MIICXQIBAAKBgQDEAwru47ES/O60GfThYB3gKMOWLd+Cac10fFRY0K6zWT8MGRyZ +EKYSyc86ZAVDjr/SZTaAkQtlsCcmOMkj2DaiSvD3wC9oOHABJyn/ssVS4WvxyNfD +XO7wN2wqm5YaBZ7rM6I5WndmYid1Hy9vONrln3ivymsiP1crvKaPR9GZbwIDAQAB +AoGAcR7IaoGhKbIrGGl6d67+zuT3q24h9aOV3Mn7653TlNHGnvbHGFcRYPpyy+H5 +X7m8XnHm+F+80hzNGzPecP9Q12oPOyoZgeQn6bTK73OFkNcX7FAkNdyH4xVhf2aK +YOzTcQfq3gRCqXtVIg4qBShTMjJLE31R8H430Or62XmJgFECQQDjP+Kz+ecQwuTB +HADLm+GQgceIB1kLgdQoZ3deUxGvqtVImuDRViSM0F2srfJ4GfkEDhc27UI5f6ir +ZTOw4ww7AkEA3M9wCPgWNtbOXbYjaNA0IzHcjMDxQDVvJAmb3EiZlKQp4EfrESxR +ly/u08TyfwrK6q5WS7xE0ad8+95G1af4XQJBAI9+3ME20SB1YItMCniHYwSj3oHX +2fN5NKWax/Zoz+c0IV+qZMHq+kNso2oRoOUTyXk1CJWndcTnBnPMALr2c9cCQQCZ +VL7Cq6uZVx6kemcqUHH0AprZbt3YLYLI7pc5p3xmeHzPzoEQQstBhjp8+aU+zPrN +blRkcQ8E2x5yNA7SLLrNAkAhzkA+EK8hc0f9W3ncy+py0Rn0i5Ay0N3T715vkThf +CfOHE3L91dLlmYpL5xVqOpugY/2sHyxwctv97DgS6tHZ -----END RSA PRIVATE KEY----- diff --git a/SSL/client-req.pem b/SSL/client-req.pem index ef11a22165f..b3667fb5ec6 100644 --- a/SSL/client-req.pem +++ b/SSL/client-req.pem @@ -1,30 +1,12 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,8CE2AB38FB50D4B9 - -rrnYZLUKlzV4U7+wqe5CWzTd4RLJb5h4M77aBRQfuHGejSaRsskN2ffpO8uQEAYM -WTJSRC+NO+jDMBZhzt1ktWqCs8d6l6azHoBybIrMJsbUhwybm+OiOfp23RrbNoS/ -S4fsgNdAAGhsRvKDdsItCyYvdH8nTzn+g9r/z2V4tOOXd6MYuT42XA6Uz2tis2SZ -GWEGa7mAweApzSiibE+pzjPS+fdX4E12n6NCVYLhn1JuvzVva/KFSebs4Wh75miC -WvRgkt/5eDQn+vkV67hE3I6p9pPcLh1+PMfaQ25U8VM/r7ejnVFWm7teGH6GKPKJ -cU+PYfblyWcgtiO/fwfGMIqSyNtHj/C3VFVie5D1MTJzBopiPGEcfz00LjBccjjh -j1meTRVN8pMZTgkxlnIFwbU6TPPvx8a9urFVQIJ4z8r2EMvYh5Cqpq87+lH9Pn0C -vzCl78Tz5QLghXNnMbbdD2aPP0PwPEXgh86iZxo06g85n0l26WUzYJlWzBYD4DrF -SbnEUAftTujEOm6MqJNLpJN6UPOtq/HvSaHl1bykGK+zU4gqHj0ur03HlF0l4xNg -OfsoNsJV+O9RUUJ0+D5eqUALJjN8TCV1wNMXOVzr/ue3QCVdlWVfZY4RPffwK9Yp -Fh52T7a2v+shhqZUQNtFDAg50Ac7deUthSWNmi5N680POnJg9KdtBdMhYLa1j3rP -D9oasSK0ugevHuQ6wUiD/95CzZlJXE9K4kTTYmaRk5MTWXhFQxdqHZo1v+pGtaNI -f+/E7q7BiNesSt31U/vkX0Tm3oJ1dgOnS8M2uxiYiKH2mJ/E32tZKw== ------END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE REQUEST----- -MIIB0jCCATsCAQAwgZExCzAJBgNVBAYTAkVFMRMwEQYDVQQIEwpTb21lLVN0YXRl -MRAwDgYDVQQHEwdUYWxsaW5uMSYwJAYDVQQKEx1NeVNRTCBkZW1vIGNsaWVudCBj -ZXJ0aWZpY2F0ZTEUMBIGA1UEAxMLVG9udSBTYW11ZWwxHTAbBgkqhkiG9w0BCQEW -DnRvbnVAbXlzcWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDo1FLN -TruWFjrwiWuQTNvgMHVaAnJiv+3avgnogNuAVDDWde3jEKUVRFspkRL+DLd2Telf -VlxFPK2ycS1qesu8BIAIdNZ99nxcdts1xPb12NSJn53MP04/c8E+QX5OCb/qGtmi -Ew3RDNrY9Ju4VCEXrtezAmGHqQH/9P6cevxnQwIDAQABoAAwDQYJKoZIhvcNAQEE -BQADgYEAvENK1JAQfC8xnrFGw2IxfUmUwlRidiRtYTgtVfTr7vA+m4WaaKioni6E -PQXjcvl6kfyRoxc4qWsGi3T7QM2RnvCtbwR2NGSIKX1cBTS31RMr12NSAeXn6Twz -ZwSZ55EHj9N2hArTPNlVjxvDQX3D6/ZBi6JnHAxXigzDqhArgjU= +MIIBvDCCASUCAQAwfDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAP +BgNVBAoTCE15U1FMIEFCMRUwEwYDVQQDEwxNeVNRTCBDbGllbnQxMTAvBgkqhkiG +9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wgZ8wDQYJ +KoZIhvcNAQEBBQADgY0AMIGJAoGBAMQDCu7jsRL87rQZ9OFgHeAow5Yt34JpzXR8 +VFjQrrNZPwwZHJkQphLJzzpkBUOOv9JlNoCRC2WwJyY4ySPYNqJK8PfAL2g4cAEn +Kf+yxVLha/HI18Nc7vA3bCqblhoFnuszojlad2ZiJ3UfL2842uWfeK/KayI/Vyu8 +po9H0ZlvAgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQAnKdk68dGJXvlj/GXwBUWN +oXWF7hq4fDmwyhmcFUqk8qZKPKFUxkcER0GLzYeUgvD2URSfaS3/YW0d7K7kXGwP +rB5edb+suaYf6mjm/w37xw/EJI9rdSKcB/3SSu8mALds7sUHDAO+MO0WkA/9d7t0 +LOsUqcDvMkKpZuYwNILwLw== -----END CERTIFICATE REQUEST----- diff --git a/SSL/server-cert.pem b/SSL/server-cert.pem index b15bd04a25c..9ce296482db 100644 --- a/SSL/server-cert.pem +++ b/SSL/server-cert.pem @@ -3,24 +3,24 @@ Certificate: Version: 3 (0x2) Serial Number: 1 (0x1) Signature Algorithm: md5WithRSAEncryption - Issuer: C=RU, ST=Some-State, L=Orenburg, O=MySQL AB, CN=Walrus/Email=walrus@mysql.com + Issuer: C=SE, L=Uppsala, O=MySQL AB, CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com Validity - Not Before: Aug 2 21:59:26 2002 GMT - Not After : Aug 2 21:59:26 2003 GMT - Subject: C=RU, L=Orenburg, O=MySQL AB, CN=server/Email=walrus@mysql.com + Not Before: Aug 7 11:39:27 2003 GMT + Not After : Aug 4 11:39:27 2013 GMT + Subject: C=SE, L=Uppsala, O=MySQL AB, CN=MySQL Server/Email=abstract.mysql.developer@mysql.com Subject Public Key Info: Public Key Algorithm: rsaEncryption RSA Public Key: (1024 bit) Modulus (1024 bit): - 00:bd:7d:f1:91:51:38:fe:4b:79:b5:ff:e0:41:ae: - 0e:a8:bb:7b:60:42:95:01:75:e7:22:74:55:7d:74: - 4d:50:51:0c:5e:09:4b:2b:0c:8e:3f:9f:14:3f:5e: - d9:25:36:9b:cc:77:35:30:e9:8c:bf:3b:bd:da:62: - 85:4c:90:c8:de:71:2c:0a:7b:dc:e6:85:fd:b4:24: - 88:a7:8f:03:3d:15:7c:59:3d:f8:73:f0:36:2a:b8: - 80:7c:d8:c7:d6:1f:6d:b2:b7:b7:48:9f:24:56:81: - 2c:2e:9c:b9:95:48:50:56:9f:1a:60:96:c4:c0:eb: - 8d:2d:55:38:3f:6b:82:bc:b3 + 00:e9:86:7a:55:84:88:4c:be:a4:f8:92:73:30:12: + 49:0b:7a:85:87:39:34:39:0d:7d:0b:8d:18:c2:17: + 95:13:52:d2:3f:55:10:57:c8:3f:5a:f5:b2:fa:8b: + d0:67:49:cc:aa:82:fc:9f:ce:00:b4:73:f3:36:d2: + 3a:d3:c2:b0:0e:14:c3:d4:b2:21:74:a1:f0:31:81: + 60:87:98:73:5c:10:c1:b1:1a:4d:f1:f3:b0:98:3f: + f0:d7:97:9b:2b:fd:d5:21:79:b2:2f:eb:64:15:c9: + 9b:9d:fc:9e:2d:d4:f8:04:5b:ea:a9:75:4b:42:c3: + 3d:0e:4d:2a:a8:b8:ca:99:8d Exponent: 65537 (0x10001) X509v3 extensions: X509v3 Basic Constraints: @@ -28,38 +28,40 @@ Certificate: Netscape Comment: OpenSSL Generated Certificate X509v3 Subject Key Identifier: - C9:D0:D2:F7:17:79:27:1C:4B:C9:E7:92:D5:5E:8C:7E:F2:FE:A7:B7 + 6E:E4:9B:6A:C5:EA:E4:E6:C7:EF:D7:1E:C8:63:45:60:2B:1B:D4:D4 X509v3 Authority Key Identifier: - keyid:D9:D8:6A:7D:AB:CE:10:62:1A:16:FC:E9:6A:F4:DC:F1:66:AC:D0:B9 - DirName:/C=RU/ST=Some-State/L=Orenburg/O=MySQL AB/CN=Walrus/Email=walrus@mysql.com + keyid:95:4A:41:3E:F1:5C:12:B4:7B:3E:9F:3B:0C:23:66:90:3D:7F:4E:D8 + DirName:/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com serial:00 Signature Algorithm: md5WithRSAEncryption - 62:77:bc:16:dc:4c:70:63:4d:03:ce:19:5e:c4:6c:31:0e:57: - 26:d8:6e:25:08:f2:01:ae:98:59:0a:ba:b7:32:c0:39:69:b8: - 4b:aa:59:7c:97:72:4e:50:02:ee:ef:d6:d6:62:b8:25:36:91: - b6:3b:8f:6f:2f:3c:d8:9d:b7:cf:8f:f6:29:50:e9:31:54:77: - 2b:7b:21:72:0f:60:4c:d4:1c:bb:c4:46:e5:fd:a7:5f:ea:46: - e4:df:e9:95:77:2d:91:f8:3b:33:78:83:5d:10:de:98:7c:38: - 91:27:f6:52:8a:b6:54:f1:0f:7a:f0:1d:da:a5:22:d2:75:cc: - 4c:c3 + 7c:b6:9c:fc:ea:9e:e6:88:32:f5:24:81:9b:89:c0:13:fa:75: + 18:51:af:77:ae:b8:4e:12:5f:48:ab:0c:e6:c5:a4:87:93:6e: + 98:97:f5:f3:d3:0b:e0:fc:5e:34:3e:f2:93:58:73:97:b6:a7: + 66:96:81:cd:73:48:f3:75:24:64:61:13:78:3e:ed:df:7c:4d: + fa:2e:3a:64:99:12:24:9e:a2:51:5c:23:85:0b:0c:bb:f5:8e: + 89:80:27:ba:7c:d2:68:90:ff:1f:68:2e:1b:fd:06:bc:c8:41: + d7:b2:be:9c:94:5c:6d:1e:96:3b:75:bc:12:f0:44:bd:36:00: + 84:cd -----BEGIN CERTIFICATE----- -MIIDWTCCAsKgAwIBAgIBATANBgkqhkiG9w0BAQQFADB6MQswCQYDVQQGEwJSVTET -MBEGA1UECBMKU29tZS1TdGF0ZTERMA8GA1UEBxMIT3JlbmJ1cmcxETAPBgNVBAoT -CE15U1FMIEFCMQ8wDQYDVQQDEwZXYWxydXMxHzAdBgkqhkiG9w0BCQEWEHdhbHJ1 -c0BteXNxbC5jb20wHhcNMDIwODAyMjE1OTI2WhcNMDMwODAyMjE1OTI2WjBlMQsw -CQYDVQQGEwJSVTERMA8GA1UEBxMIT3JlbmJ1cmcxETAPBgNVBAoTCE15U1FMIEFC -MQ8wDQYDVQQDEwZzZXJ2ZXIxHzAdBgkqhkiG9w0BCQEWEHdhbHJ1c0BteXNxbC5j -b20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL198ZFROP5LebX/4EGuDqi7 -e2BClQF15yJ0VX10TVBRDF4JSysMjj+fFD9e2SU2m8x3NTDpjL87vdpihUyQyN5x -LAp73OaF/bQkiKePAz0VfFk9+HPwNiq4gHzYx9YfbbK3t0ifJFaBLC6cuZVIUFaf -GmCWxMDrjS1VOD9rgryzAgMBAAGjggECMIH/MAkGA1UdEwQCMAAwLAYJYIZIAYb4 -QgENBB8WHU9wZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBTJ -0NL3F3knHEvJ55LVXox+8v6ntzCBpAYDVR0jBIGcMIGZgBTZ2Gp9q84QYhoW/Olq -9NzxZqzQuaF+pHwwejELMAkGA1UEBhMCUlUxEzARBgNVBAgTClNvbWUtU3RhdGUx -ETAPBgNVBAcTCE9yZW5idXJnMREwDwYDVQQKEwhNeVNRTCBBQjEPMA0GA1UEAxMG -V2FscnVzMR8wHQYJKoZIhvcNAQkBFhB3YWxydXNAbXlzcWwuY29tggEAMA0GCSqG -SIb3DQEBBAUAA4GBAGJ3vBbcTHBjTQPOGV7EbDEOVybYbiUI8gGumFkKurcywDlp -uEuqWXyXck5QAu7v1tZiuCU2kbY7j28vPNidt8+P9ilQ6TFUdyt7IXIPYEzUHLvE -RuX9p1/qRuTf6ZV3LZH4OzN4g10Q3ph8OJEn9lKKtlTxD3rwHdqlItJ1zEzD +MIIDkTCCAvqgAwIBAgIBATANBgkqhkiG9w0BAQQFADCBiDELMAkGA1UEBhMCU0Ux +EDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoTCE15U1FMIEFCMSEwHwYDVQQDExhB +YnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAvBgkqhkiG9w0BCQEWImFic3RyYWN0 +Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wHhcNMDMwODA3MTEzOTI3WhcNMTMw +ODA0MTEzOTI3WjB8MQswCQYDVQQGEwJTRTEQMA4GA1UEBxMHVXBwc2FsYTERMA8G +A1UEChMITXlTUUwgQUIxFTATBgNVBAMTDE15U1FMIFNlcnZlcjExMC8GCSqGSIb3 +DQEJARYiYWJzdHJhY3QubXlzcWwuZGV2ZWxvcGVyQG15c3FsLmNvbTCBnzANBgkq +hkiG9w0BAQEFAAOBjQAwgYkCgYEA6YZ6VYSITL6k+JJzMBJJC3qFhzk0OQ19C40Y +wheVE1LSP1UQV8g/WvWy+ovQZ0nMqoL8n84AtHPzNtI608KwDhTD1LIhdKHwMYFg +h5hzXBDBsRpN8fOwmD/w15ebK/3VIXmyL+tkFcmbnfyeLdT4BFvqqXVLQsM9Dk0q +qLjKmY0CAwEAAaOCARQwggEQMAkGA1UdEwQCMAAwLAYJYIZIAYb4QgENBB8WHU9w +ZW5TU0wgR2VuZXJhdGVkIENlcnRpZmljYXRlMB0GA1UdDgQWBBRu5Jtqxerk5sfv +1x7IY0VgKxvU1DCBtQYDVR0jBIGtMIGqgBSVSkE+8VwStHs+nzsMI2aQPX9O2KGB +jqSBizCBiDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAPBgNVBAoT +CE15U1FMIEFCMSEwHwYDVQQDExhBYnN0cmFjdCBNeVNRTCBEZXZlbG9wZXIxMTAv +BgkqhkiG9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb22C +AQAwDQYJKoZIhvcNAQEEBQADgYEAfLac/Oqe5ogy9SSBm4nAE/p1GFGvd664ThJf +SKsM5sWkh5NumJf189ML4PxeND7yk1hzl7anZpaBzXNI83UkZGETeD7t33xN+i46 +ZJkSJJ6iUVwjhQsMu/WOiYAnunzSaJD/H2guG/0GvMhB17K+nJRcbR6WO3W8EvBE +vTYAhM0= -----END CERTIFICATE----- diff --git a/SSL/server-key.pem b/SSL/server-key.pem index 5afd717e07c..4292dc79929 100644 --- a/SSL/server-key.pem +++ b/SSL/server-key.pem @@ -1,15 +1,15 @@ -----BEGIN RSA PRIVATE KEY----- -MIICXAIBAAKBgQC9ffGRUTj+S3m1/+BBrg6ou3tgQpUBdecidFV9dE1QUQxeCUsr -DI4/nxQ/XtklNpvMdzUw6Yy/O73aYoVMkMjecSwKe9zmhf20JIinjwM9FXxZPfhz -8DYquIB82MfWH22yt7dInyRWgSwunLmVSFBWnxpglsTA640tVTg/a4K8swIDAQAB -AoGARciG2NRHn+aduPe1V5rJDTyWD/oVM8d+ykJ7ZUsaWdSvMEZN51mlXSqxYzED -2N+GesL/1LZ9vcM7hJw5qNu9DQOc7CtMT4k/bmhPJsT226roKKVbw/ocOEY5dK8+ -T9/x8qgo7zC3Qk/bKgjj61m8cQ7Mz/J7ZCEMmDNNrORCzRECQQDrcvJlsBTALilr -MaAqNyaa0tykEabzg2mUFx5uvmzlwNx9ApSidoU5Xop9c6u00zgCDpsDlcwjhOs1 -jcqRkBTrAkEAzggY7BeN3FnW8tsV0Wq4LL6vK30pe0JIylxrKsFjY4LTo9t/8TKK -6ZOEETVtM7sepIkxECw5RCBi9sxi3NClWQJAbrA5WKjw+HA7NJO98lq/IWYkKFXM -IQsUpXRA8FtBormKbpK6Aa6qbxANF3E7teTencj0Azl3IPOqCCFCrDAKRQJAc6bv -9ncyVqLHmgOJN8ikIdnYEp1rj5khqxY9wf5UgCOMEcrBAu/QMlVwKQjIh+VdyhaI -x/9LFgboBomsZS9p4QJBAIXaX/WoqL/wgBGS2UroianFFXL6/Bt//CUoGpYgKQYQ -+x+8heMRppmM0to2J7j9nGE83ikMWfPUwMi4TbyWH3Q= +MIICXgIBAAKBgQDphnpVhIhMvqT4knMwEkkLeoWHOTQ5DX0LjRjCF5UTUtI/VRBX +yD9a9bL6i9BnScyqgvyfzgC0c/M20jrTwrAOFMPUsiF0ofAxgWCHmHNcEMGxGk3x +87CYP/DXl5sr/dUhebIv62QVyZud/J4t1PgEW+qpdUtCwz0OTSqouMqZjQIDAQAB +AoGBALTq11nrjIEQbdSZ+R1z/R0kddB2U+wjdA3/6P9tr7PBxVsFdtzbKaI5mcib +iwCKX0J2qmrP+SHUdsexBZxLR4KV/Z55v9Pym99Dy+DxDA95zURyCMKRBIzlU5uN +F7USEQoltLUCsmZwNWdit0gfxSWdddkHNuI0uxTzHwuDcUlNAkEA/76zVremngNL +DlekM9NPn/8E/TXBHN1b1jdUKd7WymSJykdcm3viU98dFNZFWF8B0jiTcuBKXgpR +vTShNab/swJBAOnCGp554BLhioTyyk8qjRLt3xEsjsDljJULHVLYWcUqIkMf97GL +VLBhl6ZEI9i0WduqvgZ+Bacd0uHqIHz1Yb8CQQDm1CjqTDiGxlIoT9JVNJTZxEOs +h6gVdXY+kxHT+N3FL5luiZp8fAR7zxVgiUVtzdLG+2madfapiobcT3RyCJkhAkBI +64AaR7KasTjg2Ew7/e4cJZAcb2XozrLYG6t+GHeIhehCQEqoW+qDSy5fc4orI7eU +SuMUa2OgCjGqv7p6wKFJAkEAznmum/MbVOBpC4FsdnIGkxyFKIbh2OLY2aUb2KkK +Ouf4S8Y5Ldgszi0fnDPRaxWJzewwZKvcff2zj+mYZeAXbA== -----END RSA PRIVATE KEY----- diff --git a/SSL/server-req.pem b/SSL/server-req.pem index 4cd6610e735..7c3db0660ad 100644 --- a/SSL/server-req.pem +++ b/SSL/server-req.pem @@ -1,30 +1,12 @@ ------BEGIN RSA PRIVATE KEY----- -Proc-Type: 4,ENCRYPTED -DEK-Info: DES-EDE3-CBC,6CBD09E71246DC01 - -byRzq5+j3r8FX2kQerTUZT5Bw/N6zrN3cmH6NHGJcrqD+vcPdtWf+Rk+mpNXgSQn -ldkfmniU/htzJ0cUV+KE229Qx10Hx9mIJIbf0Y/rBCUBuaXWVrQB36W9w3rkNPFA -EEuRMkreOJF42RD16+NBJv+RcHIGzGejXecJKUGF5DKlN0U8YHXnkXTQl54kIdr0 -H7rTrvJygwPk9/ik0M9/vmwduAMvTaHDmvgeolpMlJkxwz8vYkbUnFFJZhB6XNCb -1w3lJ0EmRJicK5BnZmCEmgt8xiv0PAtg00jBbwddQbn1reAyViBtBT9iXdusHXS5 -Po63rSt7r3MO8aetcMQ6FkklH+ChuS/vFoNY57AwrzF4uEI4GSoZP0ESrRC5Ar5W -Lzg/HrQAWbPCRlb6Jj3db1woRzFS8joOashROsZdeV/5P4Emhc6J7QMTvB1OHAhQ -ugOJazJtxjg0DN8+9cM1wtHI7N89PLHhOg13LZNLeeehzIlPwKI2JLqXUc6oR407 -i+S7GCqu7wU+if0Enux8Dj7yrvnTUiqVCL2dyKTS3sBq0Cm2UhbecHclor13y6no -y1o50TKKD6Zig2hZmSpqKznMxGMVIT36BE0aOMQUmk+aVnRuROclwTTL0ZNLzA+g -QRTRfQ6iNMf34ypqAMdAMPzDGLPycKuFdxVQxFEVaM2/mrdWFwVAqFsLvzyGvdrh -nkNyRgTWR/pfH9b3mXLqf6gMPNs764WhFIcZIDk9a4XBBUm2YDb2CxDzDCo/EUMA -jvIiU0Jt132SEHHF/wAka6d2DnwZ3vexRp6Tebv/uy9IlMLPE+68dw== ------END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE REQUEST----- -MIIB0jCCATsCAQAwgZExCzAJBgNVBAYTAkVFMRMwEQYDVQQIEwpTb21lLVN0YXRl -MRAwDgYDVQQHEwdUYWxsaW5uMSYwJAYDVQQKEx1NeVNRTCBzZXJ2ZXIgZGVtbyBj -ZXJ0aWZpY2F0ZTEUMBIGA1UEAxMLVG9udSBTYW11ZWwxHTAbBgkqhkiG9w0BCQEW -DnRvbnVAbXlzcWwuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCerI3Y -HZyy/YiWLLpCU/pdvYWK5crTD8ABPPKSRk/ZgK4qic/v6NRl/Pb1OiZMKdsG+jSh -h/OXtTyU8YQFrK1XJdkC2wBx4KmqtB0pNl6ppA3yRbmDdCtF8+IjvOdc5hG29t3E -rO1lQiw5RyrJ619FAxCrI7zKXIKat7NtZxjSxwIDAQABoAAwDQYJKoZIhvcNAQEE -BQADgYEAlrUnGX4LYIiVjztHA4gUcOSVeEHCci2qEUq+7yY1JhAw54YDa2MLTTwa -cH+rXLHjN0MTNfv9tRxdSX+trk3pyvhgFjssD100dJkF83RfVv2tKg9kscVOGQp7 -MkwOnJjfAjQBlTbTOQM46BTjv2FgvsppkO3ViryI//YxKvj/628= +MIIBvDCCASUCAQAwfDELMAkGA1UEBhMCU0UxEDAOBgNVBAcTB1VwcHNhbGExETAP +BgNVBAoTCE15U1FMIEFCMRUwEwYDVQQDEwxNeVNRTCBTZXJ2ZXIxMTAvBgkqhkiG +9w0BCQEWImFic3RyYWN0Lm15c3FsLmRldmVsb3BlckBteXNxbC5jb20wgZ8wDQYJ +KoZIhvcNAQEBBQADgY0AMIGJAoGBAOmGelWEiEy+pPiSczASSQt6hYc5NDkNfQuN +GMIXlRNS0j9VEFfIP1r1svqL0GdJzKqC/J/OALRz8zbSOtPCsA4Uw9SyIXSh8DGB +YIeYc1wQwbEaTfHzsJg/8NeXmyv91SF5si/rZBXJm538ni3U+ARb6ql1S0LDPQ5N +Kqi4ypmNAgMBAAGgADANBgkqhkiG9w0BAQQFAAOBgQCagJxGHBC+G5aSh3OguFn6 +z+qAC7u3B181kPBgNv20zMgLeq7YiAh3iNx4XO2+QXRGzMznFKx1tFr/mavCpgLs +p3+dCvQt5FHEFFK1D1pDeXy4146X07hOTtC9jc/jSWeVnH4ujuX5gMtZqisOyYWV +/gpw6dBtkTYlhS+y86kM/Q== -----END CERTIFICATE REQUEST----- diff --git a/mysql-test/r/openssl_1.result b/mysql-test/r/openssl_1.result index 65b882c0a9b..f6c7bf5bc79 100644 --- a/mysql-test/r/openssl_1.result +++ b/mysql-test/r/openssl_1.result @@ -3,8 +3,8 @@ create table t1(f1 int); insert into t1 values (5); grant select on test.* to ssl_user1@localhost require SSL; grant select on test.* to ssl_user2@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; -grant select on test.* to ssl_user3@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=RU/L=orenburg/O=MySQL AB/OU=client/CN=walrus/Email=walrus@mysql.com"; -grant select on test.* to ssl_user4@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=RU/L=orenburg/O=MySQL AB/OU=client/CN=walrus/Email=walrus@mysql.com" ISSUER "/C=RU/ST=Some-State/L=Orenburg/O=MySQL AB/CN=Walrus/Email=walrus@mysql.com"; +grant select on test.* to ssl_user3@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com"; +grant select on test.* to ssl_user4@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com"; flush privileges; select * from t1; f1 diff --git a/mysql-test/t/openssl_1.test b/mysql-test/t/openssl_1.test index 3af7406cef3..25790f24738 100644 --- a/mysql-test/t/openssl_1.test +++ b/mysql-test/t/openssl_1.test @@ -8,8 +8,8 @@ insert into t1 values (5); grant select on test.* to ssl_user1@localhost require SSL; grant select on test.* to ssl_user2@localhost require cipher "EDH-RSA-DES-CBC3-SHA"; -grant select on test.* to ssl_user3@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=RU/L=orenburg/O=MySQL AB/OU=client/CN=walrus/Email=walrus@mysql.com"; -grant select on test.* to ssl_user4@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=RU/L=orenburg/O=MySQL AB/OU=client/CN=walrus/Email=walrus@mysql.com" ISSUER "/C=RU/ST=Some-State/L=Orenburg/O=MySQL AB/CN=Walrus/Email=walrus@mysql.com"; +grant select on test.* to ssl_user3@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com"; +grant select on test.* to ssl_user4@localhost require cipher "EDH-RSA-DES-CBC3-SHA" AND SUBJECT "/C=SE/L=Uppsala/O=MySQL AB/CN=MySQL Client/Email=abstract.mysql.developer@mysql.com" ISSUER "/C=SE/L=Uppsala/O=MySQL AB/CN=Abstract MySQL Developer/Email=abstract.mysql.developer@mysql.com"; flush privileges; connect (con1,localhost,ssl_user1,,); connect (con2,localhost,ssl_user2,,); From 2e6d30072c501f30daff34c134cc4b4cba565950 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Aug 2003 18:49:22 +0200 Subject: [PATCH 015/282] between tests added bugfixes will follow --- mysql-test/r/range.result | 28 ++++++++++++++++++++++++++++ mysql-test/t/range.test | 17 +++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 26d9d7869c6..5a4d2228778 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -226,3 +226,31 @@ insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; id1 idnull drop table t1; +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 7 and t1.y+0; +table type possible_keys key key_len ref rows Extra +t1 ref y y 5 const 1 Using where +t2 ALL x NULL NULL NULL 9 Using where +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 7 and t2.x <= t1.y+0; +table type possible_keys key key_len ref rows Extra +t1 ref y y 5 const 1 Using where +t2 range x x 5 NULL 4 Using where +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +table type possible_keys key key_len ref rows Extra +t1 ref y y 5 const 1 Using where +t2 ALL x NULL NULL NULL 9 Using where +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +table type possible_keys key key_len ref rows Extra +t1 ref y y 5 const 1 Using where +t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1) +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +table type possible_keys key key_len ref rows Extra +t1 ref y y 5 const 1 Using where +t2 ALL x NULL NULL NULL 9 Using where +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +table type possible_keys key key_len ref rows Extra +t1 ref y y 5 const 1 Using where +t2 range x x 5 NULL 2 Using where +drop table t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index bb0e696ea11..521709eddee 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -183,3 +183,20 @@ insert into t1 values (0,1,NULL,"aaa"), (1,1,NULL,"aaa"), (2,1,NULL,"aaa"), select a.id1, b.idnull from t1 as a, t1 as b where a.id2=1 and a.id1=1 and b.id1=a.idnull order by b.id2 desc limit 1; drop table t1; +# +# BETWEEN problems +# +create table t1 (x int, y int, index(x), index(y)); +insert into t1 (x) values (1),(2),(3),(4),(5),(6),(7),(8),(9); +update t1 set y=x; +# between with only one end fixed +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 7 and t1.y+0; +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 7 and t2.x <= t1.y+0; +# between with both expressions on both ends +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; +# equation propagation +explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 0 and t1.y; +explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 0 and t2.x <= t1.y; +drop table t1; + From a71ef9e643f21b79fa9051cc6fc8ea27705fe8cb Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Aug 2003 19:13:27 +0200 Subject: [PATCH 016/282] between range optimization bug (between with const on one end only) --- mysql-test/r/range.result | 2 +- sql/opt_range.cc | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 5a4d2228778..4e0476fdacd 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -232,7 +232,7 @@ update t1 set y=x; explain select * from t1, t1 t2 where t1.y = 2 and t2.x between 7 and t1.y+0; table type possible_keys key key_len ref rows Extra t1 ref y y 5 const 1 Using where -t2 ALL x NULL NULL NULL 9 Using where +t2 range x x 5 NULL 4 Using where explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= 7 and t2.x <= t1.y+0; table type possible_keys key key_len ref rows Extra t1 ref y y 5 const 1 Using where diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 2d949810b63..c7bad3b18f3 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -794,18 +794,15 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) DBUG_RETURN(new SEL_TREE(SEL_TREE::ALWAYS)); DBUG_RETURN(new SEL_TREE(SEL_TREE::IMPOSSIBLE)); } + table_map ref_tables=cond->used_tables(); - if (ref_tables & ~(param->prev_tables | param->read_tables | - param->current_table)) - DBUG_RETURN(0); // Can't be calculated yet if (cond->type() != Item::FUNC_ITEM) { // Should be a field if (ref_tables & param->current_table) DBUG_RETURN(0); DBUG_RETURN(new SEL_TREE(SEL_TREE::MAYBE)); } - if (!(ref_tables & param->current_table)) - DBUG_RETURN(new SEL_TREE(SEL_TREE::MAYBE)); // This may be false or true + Item_func *cond_func= (Item_func*) cond; if (cond_func->select_optimize() == Item_func::OPTIMIZE_NONE) DBUG_RETURN(0); // Can't be calculated @@ -847,6 +844,12 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) DBUG_RETURN(0); // Can't optimize this IN } + if (ref_tables & ~(param->prev_tables | param->read_tables | + param->current_table)) + DBUG_RETURN(0); // Can't be calculated yet + if (!(ref_tables & param->current_table)) + DBUG_RETURN(new SEL_TREE(SEL_TREE::MAYBE)); // This may be false or true + /* check field op const */ /* btw, ft_func's arguments()[0] isn't FIELD_ITEM. SerG*/ if (cond_func->arguments()[0]->type() == Item::FIELD_ITEM) From 05f5df0c36c24610b7a77b361884171e3c1058a8 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 8 Aug 2003 23:27:22 +0300 Subject: [PATCH 017/282] rewritten test using loop (BUG#930) removed unused field (now it is in variables) mysql-test/r/query_cache.result: rewritten test using loop mysql-test/t/query_cache.test: rewritten test using loop sql/sql_class.h: removed unused field (now it is in variables) --- mysql-test/r/query_cache.result | 519 +------------------------------ mysql-test/t/query_cache.test | 530 +------------------------------- sql/sql_class.h | 1 - 3 files changed, 14 insertions(+), 1036 deletions(-) diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index e1fd5443580..48df3b4b563 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -2,7 +2,7 @@ flush query cache; flush query cache; reset query cache; flush status; -drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t00,mysqltest.t1; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00,mysqltest.t1; drop database if exists mysqltest; create table t1 (a int not null); insert into t1 values (1),(2),(3); @@ -641,521 +641,6 @@ Qcache_queries_in_cache 2 SET OPTION SQL_SELECT_LIMIT=DEFAULT; drop table t1; flush status; -create table t0(a int); -create table t1(a int); -create table t2(a int); -create table t3(a int); -create table t4(a int); -create table t5(a int); -create table t6(a int); -create table t7(a int); -create table t8(a int); -create table t9(a int); -create table t10(a int); -create table t11(a int); -create table t12(a int); -create table t13(a int); -create table t14(a int); -create table t15(a int); -create table t16(a int); -create table t17(a int); -create table t18(a int); -create table t19(a int); -create table t20(a int); -create table t21(a int); -create table t22(a int); -create table t23(a int); -create table t24(a int); -create table t25(a int); -create table t26(a int); -create table t27(a int); -create table t28(a int); -create table t29(a int); -create table t30(a int); -create table t31(a int); -create table t32(a int); -create table t33(a int); -create table t34(a int); -create table t35(a int); -create table t36(a int); -create table t37(a int); -create table t38(a int); -create table t39(a int); -create table t40(a int); -create table t41(a int); -create table t42(a int); -create table t43(a int); -create table t44(a int); -create table t45(a int); -create table t46(a int); -create table t47(a int); -create table t48(a int); -create table t49(a int); -create table t50(a int); -create table t51(a int); -create table t52(a int); -create table t53(a int); -create table t54(a int); -create table t55(a int); -create table t56(a int); -create table t57(a int); -create table t58(a int); -create table t59(a int); -create table t60(a int); -create table t61(a int); -create table t62(a int); -create table t63(a int); -create table t64(a int); -create table t65(a int); -create table t66(a int); -create table t67(a int); -create table t68(a int); -create table t69(a int); -create table t70(a int); -create table t71(a int); -create table t72(a int); -create table t73(a int); -create table t74(a int); -create table t75(a int); -create table t76(a int); -create table t77(a int); -create table t78(a int); -create table t79(a int); -create table t80(a int); -create table t81(a int); -create table t82(a int); -create table t83(a int); -create table t84(a int); -create table t85(a int); -create table t86(a int); -create table t87(a int); -create table t88(a int); -create table t89(a int); -create table t90(a int); -create table t91(a int); -create table t92(a int); -create table t93(a int); -create table t94(a int); -create table t95(a int); -create table t96(a int); -create table t97(a int); -create table t98(a int); -create table t99(a int); -create table t100(a int); -create table t101(a int); -create table t102(a int); -create table t103(a int); -create table t104(a int); -create table t105(a int); -create table t106(a int); -create table t107(a int); -create table t108(a int); -create table t109(a int); -create table t110(a int); -create table t111(a int); -create table t112(a int); -create table t113(a int); -create table t114(a int); -create table t115(a int); -create table t116(a int); -create table t117(a int); -create table t118(a int); -create table t119(a int); -create table t120(a int); -create table t121(a int); -create table t122(a int); -create table t123(a int); -create table t124(a int); -create table t125(a int); -create table t126(a int); -create table t127(a int); -create table t128(a int); -create table t129(a int); -create table t130(a int); -create table t131(a int); -create table t132(a int); -create table t133(a int); -create table t134(a int); -create table t135(a int); -create table t136(a int); -create table t137(a int); -create table t138(a int); -create table t139(a int); -create table t140(a int); -create table t141(a int); -create table t142(a int); -create table t143(a int); -create table t144(a int); -create table t145(a int); -create table t146(a int); -create table t147(a int); -create table t148(a int); -create table t149(a int); -create table t150(a int); -create table t151(a int); -create table t152(a int); -create table t153(a int); -create table t154(a int); -create table t155(a int); -create table t156(a int); -create table t157(a int); -create table t158(a int); -create table t159(a int); -create table t160(a int); -create table t161(a int); -create table t162(a int); -create table t163(a int); -create table t164(a int); -create table t165(a int); -create table t166(a int); -create table t167(a int); -create table t168(a int); -create table t169(a int); -create table t170(a int); -create table t171(a int); -create table t172(a int); -create table t173(a int); -create table t174(a int); -create table t175(a int); -create table t176(a int); -create table t177(a int); -create table t178(a int); -create table t179(a int); -create table t180(a int); -create table t181(a int); -create table t182(a int); -create table t183(a int); -create table t184(a int); -create table t185(a int); -create table t186(a int); -create table t187(a int); -create table t188(a int); -create table t189(a int); -create table t190(a int); -create table t191(a int); -create table t192(a int); -create table t193(a int); -create table t194(a int); -create table t195(a int); -create table t196(a int); -create table t197(a int); -create table t198(a int); -create table t199(a int); -create table t200(a int); -create table t201(a int); -create table t202(a int); -create table t203(a int); -create table t204(a int); -create table t205(a int); -create table t206(a int); -create table t207(a int); -create table t208(a int); -create table t209(a int); -create table t210(a int); -create table t211(a int); -create table t212(a int); -create table t213(a int); -create table t214(a int); -create table t215(a int); -create table t216(a int); -create table t217(a int); -create table t218(a int); -create table t219(a int); -create table t220(a int); -create table t221(a int); -create table t222(a int); -create table t223(a int); -create table t224(a int); -create table t225(a int); -create table t226(a int); -create table t227(a int); -create table t228(a int); -create table t229(a int); -create table t230(a int); -create table t231(a int); -create table t232(a int); -create table t233(a int); -create table t234(a int); -create table t235(a int); -create table t236(a int); -create table t237(a int); -create table t238(a int); -create table t239(a int); -create table t240(a int); -create table t241(a int); -create table t242(a int); -create table t243(a int); -create table t244(a int); -create table t245(a int); -create table t246(a int); -create table t247(a int); -create table t248(a int); -create table t249(a int); -create table t250(a int); -create table t251(a int); -create table t252(a int); -create table t253(a int); -create table t254(a int); -create table t255(a int); -create table t256(a int); -create table t00 (a int) type=MERGE UNION=(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256) INSERT_METHOD=FIRST; -insert into t0 values (1),(2); -insert into t1 values (1),(2); -insert into t2 values (1),(2); -insert into t3 values (1),(2); -insert into t4 values (1),(2); -insert into t5 values (1),(2); -insert into t6 values (1),(2); -insert into t7 values (1),(2); -insert into t8 values (1),(2); -insert into t9 values (1),(2); -insert into t10 values (1),(2); -insert into t11 values (1),(2); -insert into t12 values (1),(2); -insert into t13 values (1),(2); -insert into t14 values (1),(2); -insert into t15 values (1),(2); -insert into t16 values (1),(2); -insert into t17 values (1),(2); -insert into t18 values (1),(2); -insert into t19 values (1),(2); -insert into t20 values (1),(2); -insert into t21 values (1),(2); -insert into t22 values (1),(2); -insert into t23 values (1),(2); -insert into t24 values (1),(2); -insert into t25 values (1),(2); -insert into t26 values (1),(2); -insert into t27 values (1),(2); -insert into t28 values (1),(2); -insert into t29 values (1),(2); -insert into t30 values (1),(2); -insert into t31 values (1),(2); -insert into t32 values (1),(2); -insert into t33 values (1),(2); -insert into t34 values (1),(2); -insert into t35 values (1),(2); -insert into t36 values (1),(2); -insert into t37 values (1),(2); -insert into t38 values (1),(2); -insert into t39 values (1),(2); -insert into t40 values (1),(2); -insert into t41 values (1),(2); -insert into t42 values (1),(2); -insert into t43 values (1),(2); -insert into t44 values (1),(2); -insert into t45 values (1),(2); -insert into t46 values (1),(2); -insert into t47 values (1),(2); -insert into t48 values (1),(2); -insert into t49 values (1),(2); -insert into t50 values (1),(2); -insert into t51 values (1),(2); -insert into t52 values (1),(2); -insert into t53 values (1),(2); -insert into t54 values (1),(2); -insert into t55 values (1),(2); -insert into t56 values (1),(2); -insert into t57 values (1),(2); -insert into t58 values (1),(2); -insert into t59 values (1),(2); -insert into t60 values (1),(2); -insert into t61 values (1),(2); -insert into t62 values (1),(2); -insert into t63 values (1),(2); -insert into t64 values (1),(2); -insert into t65 values (1),(2); -insert into t66 values (1),(2); -insert into t67 values (1),(2); -insert into t68 values (1),(2); -insert into t69 values (1),(2); -insert into t70 values (1),(2); -insert into t71 values (1),(2); -insert into t72 values (1),(2); -insert into t73 values (1),(2); -insert into t74 values (1),(2); -insert into t75 values (1),(2); -insert into t76 values (1),(2); -insert into t77 values (1),(2); -insert into t78 values (1),(2); -insert into t79 values (1),(2); -insert into t80 values (1),(2); -insert into t81 values (1),(2); -insert into t82 values (1),(2); -insert into t83 values (1),(2); -insert into t84 values (1),(2); -insert into t85 values (1),(2); -insert into t86 values (1),(2); -insert into t87 values (1),(2); -insert into t88 values (1),(2); -insert into t89 values (1),(2); -insert into t90 values (1),(2); -insert into t91 values (1),(2); -insert into t92 values (1),(2); -insert into t93 values (1),(2); -insert into t94 values (1),(2); -insert into t95 values (1),(2); -insert into t96 values (1),(2); -insert into t97 values (1),(2); -insert into t98 values (1),(2); -insert into t99 values (1),(2); -insert into t100 values (1),(2); -insert into t101 values (1),(2); -insert into t102 values (1),(2); -insert into t103 values (1),(2); -insert into t104 values (1),(2); -insert into t105 values (1),(2); -insert into t106 values (1),(2); -insert into t107 values (1),(2); -insert into t108 values (1),(2); -insert into t109 values (1),(2); -insert into t110 values (1),(2); -insert into t111 values (1),(2); -insert into t112 values (1),(2); -insert into t113 values (1),(2); -insert into t114 values (1),(2); -insert into t115 values (1),(2); -insert into t116 values (1),(2); -insert into t117 values (1),(2); -insert into t118 values (1),(2); -insert into t119 values (1),(2); -insert into t120 values (1),(2); -insert into t121 values (1),(2); -insert into t122 values (1),(2); -insert into t123 values (1),(2); -insert into t124 values (1),(2); -insert into t125 values (1),(2); -insert into t126 values (1),(2); -insert into t127 values (1),(2); -insert into t128 values (1),(2); -insert into t129 values (1),(2); -insert into t130 values (1),(2); -insert into t131 values (1),(2); -insert into t132 values (1),(2); -insert into t133 values (1),(2); -insert into t134 values (1),(2); -insert into t135 values (1),(2); -insert into t136 values (1),(2); -insert into t137 values (1),(2); -insert into t138 values (1),(2); -insert into t139 values (1),(2); -insert into t140 values (1),(2); -insert into t141 values (1),(2); -insert into t142 values (1),(2); -insert into t143 values (1),(2); -insert into t144 values (1),(2); -insert into t145 values (1),(2); -insert into t146 values (1),(2); -insert into t147 values (1),(2); -insert into t148 values (1),(2); -insert into t149 values (1),(2); -insert into t150 values (1),(2); -insert into t151 values (1),(2); -insert into t152 values (1),(2); -insert into t153 values (1),(2); -insert into t154 values (1),(2); -insert into t155 values (1),(2); -insert into t156 values (1),(2); -insert into t157 values (1),(2); -insert into t158 values (1),(2); -insert into t159 values (1),(2); -insert into t160 values (1),(2); -insert into t161 values (1),(2); -insert into t162 values (1),(2); -insert into t163 values (1),(2); -insert into t164 values (1),(2); -insert into t165 values (1),(2); -insert into t166 values (1),(2); -insert into t167 values (1),(2); -insert into t168 values (1),(2); -insert into t169 values (1),(2); -insert into t170 values (1),(2); -insert into t171 values (1),(2); -insert into t172 values (1),(2); -insert into t173 values (1),(2); -insert into t174 values (1),(2); -insert into t175 values (1),(2); -insert into t176 values (1),(2); -insert into t177 values (1),(2); -insert into t178 values (1),(2); -insert into t179 values (1),(2); -insert into t180 values (1),(2); -insert into t181 values (1),(2); -insert into t182 values (1),(2); -insert into t183 values (1),(2); -insert into t184 values (1),(2); -insert into t185 values (1),(2); -insert into t186 values (1),(2); -insert into t187 values (1),(2); -insert into t188 values (1),(2); -insert into t189 values (1),(2); -insert into t190 values (1),(2); -insert into t191 values (1),(2); -insert into t192 values (1),(2); -insert into t193 values (1),(2); -insert into t194 values (1),(2); -insert into t195 values (1),(2); -insert into t196 values (1),(2); -insert into t197 values (1),(2); -insert into t198 values (1),(2); -insert into t199 values (1),(2); -insert into t200 values (1),(2); -insert into t201 values (1),(2); -insert into t202 values (1),(2); -insert into t203 values (1),(2); -insert into t204 values (1),(2); -insert into t205 values (1),(2); -insert into t206 values (1),(2); -insert into t207 values (1),(2); -insert into t208 values (1),(2); -insert into t209 values (1),(2); -insert into t210 values (1),(2); -insert into t211 values (1),(2); -insert into t212 values (1),(2); -insert into t213 values (1),(2); -insert into t214 values (1),(2); -insert into t215 values (1),(2); -insert into t216 values (1),(2); -insert into t217 values (1),(2); -insert into t218 values (1),(2); -insert into t219 values (1),(2); -insert into t220 values (1),(2); -insert into t221 values (1),(2); -insert into t222 values (1),(2); -insert into t223 values (1),(2); -insert into t224 values (1),(2); -insert into t225 values (1),(2); -insert into t226 values (1),(2); -insert into t227 values (1),(2); -insert into t228 values (1),(2); -insert into t229 values (1),(2); -insert into t230 values (1),(2); -insert into t231 values (1),(2); -insert into t232 values (1),(2); -insert into t233 values (1),(2); -insert into t234 values (1),(2); -insert into t235 values (1),(2); -insert into t236 values (1),(2); -insert into t237 values (1),(2); -insert into t238 values (1),(2); -insert into t239 values (1),(2); -insert into t240 values (1),(2); -insert into t241 values (1),(2); -insert into t242 values (1),(2); -insert into t243 values (1),(2); -insert into t244 values (1),(2); -insert into t245 values (1),(2); -insert into t246 values (1),(2); -insert into t247 values (1),(2); -insert into t248 values (1),(2); -insert into t249 values (1),(2); -insert into t250 values (1),(2); -insert into t251 values (1),(2); -insert into t252 values (1),(2); -insert into t253 values (1),(2); -insert into t254 values (1),(2); -insert into t255 values (1),(2); -insert into t256 values (1),(2); select count(*) from t00; count(*) 514 @@ -1172,4 +657,4 @@ delete from t256; show status like "Qcache_queries_in_cache"; Variable_name Value Qcache_queries_in_cache 0 -drop table t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t00; +drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index 6907a9e8299..f72a4a504a0 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -10,7 +10,7 @@ flush query cache; # This crashed in some versions flush query cache; # This crashed in some versions reset query cache; flush status; -drop table if exists t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t00,mysqltest.t1; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00,mysqltest.t1; drop database if exists mysqltest; # @@ -455,526 +455,20 @@ drop table t1; # more then 255 (257) merged tables test # flush status; -create table t0(a int); -create table t1(a int); -create table t2(a int); -create table t3(a int); -create table t4(a int); -create table t5(a int); -create table t6(a int); -create table t7(a int); -create table t8(a int); -create table t9(a int); -create table t10(a int); -create table t11(a int); -create table t12(a int); -create table t13(a int); -create table t14(a int); -create table t15(a int); -create table t16(a int); -create table t17(a int); -create table t18(a int); -create table t19(a int); -create table t20(a int); -create table t21(a int); -create table t22(a int); -create table t23(a int); -create table t24(a int); -create table t25(a int); -create table t26(a int); -create table t27(a int); -create table t28(a int); -create table t29(a int); -create table t30(a int); -create table t31(a int); -create table t32(a int); -create table t33(a int); -create table t34(a int); -create table t35(a int); -create table t36(a int); -create table t37(a int); -create table t38(a int); -create table t39(a int); -create table t40(a int); -create table t41(a int); -create table t42(a int); -create table t43(a int); -create table t44(a int); -create table t45(a int); -create table t46(a int); -create table t47(a int); -create table t48(a int); -create table t49(a int); -create table t50(a int); -create table t51(a int); -create table t52(a int); -create table t53(a int); -create table t54(a int); -create table t55(a int); -create table t56(a int); -create table t57(a int); -create table t58(a int); -create table t59(a int); -create table t60(a int); -create table t61(a int); -create table t62(a int); -create table t63(a int); -create table t64(a int); -create table t65(a int); -create table t66(a int); -create table t67(a int); -create table t68(a int); -create table t69(a int); -create table t70(a int); -create table t71(a int); -create table t72(a int); -create table t73(a int); -create table t74(a int); -create table t75(a int); -create table t76(a int); -create table t77(a int); -create table t78(a int); -create table t79(a int); -create table t80(a int); -create table t81(a int); -create table t82(a int); -create table t83(a int); -create table t84(a int); -create table t85(a int); -create table t86(a int); -create table t87(a int); -create table t88(a int); -create table t89(a int); -create table t90(a int); -create table t91(a int); -create table t92(a int); -create table t93(a int); -create table t94(a int); -create table t95(a int); -create table t96(a int); -create table t97(a int); -create table t98(a int); -create table t99(a int); -create table t100(a int); -create table t101(a int); -create table t102(a int); -create table t103(a int); -create table t104(a int); -create table t105(a int); -create table t106(a int); -create table t107(a int); -create table t108(a int); -create table t109(a int); -create table t110(a int); -create table t111(a int); -create table t112(a int); -create table t113(a int); -create table t114(a int); -create table t115(a int); -create table t116(a int); -create table t117(a int); -create table t118(a int); -create table t119(a int); -create table t120(a int); -create table t121(a int); -create table t122(a int); -create table t123(a int); -create table t124(a int); -create table t125(a int); -create table t126(a int); -create table t127(a int); -create table t128(a int); -create table t129(a int); -create table t130(a int); -create table t131(a int); -create table t132(a int); -create table t133(a int); -create table t134(a int); -create table t135(a int); -create table t136(a int); -create table t137(a int); -create table t138(a int); -create table t139(a int); -create table t140(a int); -create table t141(a int); -create table t142(a int); -create table t143(a int); -create table t144(a int); -create table t145(a int); -create table t146(a int); -create table t147(a int); -create table t148(a int); -create table t149(a int); -create table t150(a int); -create table t151(a int); -create table t152(a int); -create table t153(a int); -create table t154(a int); -create table t155(a int); -create table t156(a int); -create table t157(a int); -create table t158(a int); -create table t159(a int); -create table t160(a int); -create table t161(a int); -create table t162(a int); -create table t163(a int); -create table t164(a int); -create table t165(a int); -create table t166(a int); -create table t167(a int); -create table t168(a int); -create table t169(a int); -create table t170(a int); -create table t171(a int); -create table t172(a int); -create table t173(a int); -create table t174(a int); -create table t175(a int); -create table t176(a int); -create table t177(a int); -create table t178(a int); -create table t179(a int); -create table t180(a int); -create table t181(a int); -create table t182(a int); -create table t183(a int); -create table t184(a int); -create table t185(a int); -create table t186(a int); -create table t187(a int); -create table t188(a int); -create table t189(a int); -create table t190(a int); -create table t191(a int); -create table t192(a int); -create table t193(a int); -create table t194(a int); -create table t195(a int); -create table t196(a int); -create table t197(a int); -create table t198(a int); -create table t199(a int); -create table t200(a int); -create table t201(a int); -create table t202(a int); -create table t203(a int); -create table t204(a int); -create table t205(a int); -create table t206(a int); -create table t207(a int); -create table t208(a int); -create table t209(a int); -create table t210(a int); -create table t211(a int); -create table t212(a int); -create table t213(a int); -create table t214(a int); -create table t215(a int); -create table t216(a int); -create table t217(a int); -create table t218(a int); -create table t219(a int); -create table t220(a int); -create table t221(a int); -create table t222(a int); -create table t223(a int); -create table t224(a int); -create table t225(a int); -create table t226(a int); -create table t227(a int); -create table t228(a int); -create table t229(a int); -create table t230(a int); -create table t231(a int); -create table t232(a int); -create table t233(a int); -create table t234(a int); -create table t235(a int); -create table t236(a int); -create table t237(a int); -create table t238(a int); -create table t239(a int); -create table t240(a int); -create table t241(a int); -create table t242(a int); -create table t243(a int); -create table t244(a int); -create table t245(a int); -create table t246(a int); -create table t247(a int); -create table t248(a int); -create table t249(a int); -create table t250(a int); -create table t251(a int); -create table t252(a int); -create table t253(a int); -create table t254(a int); -create table t255(a int); -create table t256(a int); -create table t00 (a int) type=MERGE UNION=(t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256) INSERT_METHOD=FIRST; -insert into t0 values (1),(2); -insert into t1 values (1),(2); -insert into t2 values (1),(2); -insert into t3 values (1),(2); -insert into t4 values (1),(2); -insert into t5 values (1),(2); -insert into t6 values (1),(2); -insert into t7 values (1),(2); -insert into t8 values (1),(2); -insert into t9 values (1),(2); -insert into t10 values (1),(2); -insert into t11 values (1),(2); -insert into t12 values (1),(2); -insert into t13 values (1),(2); -insert into t14 values (1),(2); -insert into t15 values (1),(2); -insert into t16 values (1),(2); -insert into t17 values (1),(2); -insert into t18 values (1),(2); -insert into t19 values (1),(2); -insert into t20 values (1),(2); -insert into t21 values (1),(2); -insert into t22 values (1),(2); -insert into t23 values (1),(2); -insert into t24 values (1),(2); -insert into t25 values (1),(2); -insert into t26 values (1),(2); -insert into t27 values (1),(2); -insert into t28 values (1),(2); -insert into t29 values (1),(2); -insert into t30 values (1),(2); -insert into t31 values (1),(2); -insert into t32 values (1),(2); -insert into t33 values (1),(2); -insert into t34 values (1),(2); -insert into t35 values (1),(2); -insert into t36 values (1),(2); -insert into t37 values (1),(2); -insert into t38 values (1),(2); -insert into t39 values (1),(2); -insert into t40 values (1),(2); -insert into t41 values (1),(2); -insert into t42 values (1),(2); -insert into t43 values (1),(2); -insert into t44 values (1),(2); -insert into t45 values (1),(2); -insert into t46 values (1),(2); -insert into t47 values (1),(2); -insert into t48 values (1),(2); -insert into t49 values (1),(2); -insert into t50 values (1),(2); -insert into t51 values (1),(2); -insert into t52 values (1),(2); -insert into t53 values (1),(2); -insert into t54 values (1),(2); -insert into t55 values (1),(2); -insert into t56 values (1),(2); -insert into t57 values (1),(2); -insert into t58 values (1),(2); -insert into t59 values (1),(2); -insert into t60 values (1),(2); -insert into t61 values (1),(2); -insert into t62 values (1),(2); -insert into t63 values (1),(2); -insert into t64 values (1),(2); -insert into t65 values (1),(2); -insert into t66 values (1),(2); -insert into t67 values (1),(2); -insert into t68 values (1),(2); -insert into t69 values (1),(2); -insert into t70 values (1),(2); -insert into t71 values (1),(2); -insert into t72 values (1),(2); -insert into t73 values (1),(2); -insert into t74 values (1),(2); -insert into t75 values (1),(2); -insert into t76 values (1),(2); -insert into t77 values (1),(2); -insert into t78 values (1),(2); -insert into t79 values (1),(2); -insert into t80 values (1),(2); -insert into t81 values (1),(2); -insert into t82 values (1),(2); -insert into t83 values (1),(2); -insert into t84 values (1),(2); -insert into t85 values (1),(2); -insert into t86 values (1),(2); -insert into t87 values (1),(2); -insert into t88 values (1),(2); -insert into t89 values (1),(2); -insert into t90 values (1),(2); -insert into t91 values (1),(2); -insert into t92 values (1),(2); -insert into t93 values (1),(2); -insert into t94 values (1),(2); -insert into t95 values (1),(2); -insert into t96 values (1),(2); -insert into t97 values (1),(2); -insert into t98 values (1),(2); -insert into t99 values (1),(2); -insert into t100 values (1),(2); -insert into t101 values (1),(2); -insert into t102 values (1),(2); -insert into t103 values (1),(2); -insert into t104 values (1),(2); -insert into t105 values (1),(2); -insert into t106 values (1),(2); -insert into t107 values (1),(2); -insert into t108 values (1),(2); -insert into t109 values (1),(2); -insert into t110 values (1),(2); -insert into t111 values (1),(2); -insert into t112 values (1),(2); -insert into t113 values (1),(2); -insert into t114 values (1),(2); -insert into t115 values (1),(2); -insert into t116 values (1),(2); -insert into t117 values (1),(2); -insert into t118 values (1),(2); -insert into t119 values (1),(2); -insert into t120 values (1),(2); -insert into t121 values (1),(2); -insert into t122 values (1),(2); -insert into t123 values (1),(2); -insert into t124 values (1),(2); -insert into t125 values (1),(2); -insert into t126 values (1),(2); -insert into t127 values (1),(2); -insert into t128 values (1),(2); -insert into t129 values (1),(2); -insert into t130 values (1),(2); -insert into t131 values (1),(2); -insert into t132 values (1),(2); -insert into t133 values (1),(2); -insert into t134 values (1),(2); -insert into t135 values (1),(2); -insert into t136 values (1),(2); -insert into t137 values (1),(2); -insert into t138 values (1),(2); -insert into t139 values (1),(2); -insert into t140 values (1),(2); -insert into t141 values (1),(2); -insert into t142 values (1),(2); -insert into t143 values (1),(2); -insert into t144 values (1),(2); -insert into t145 values (1),(2); -insert into t146 values (1),(2); -insert into t147 values (1),(2); -insert into t148 values (1),(2); -insert into t149 values (1),(2); -insert into t150 values (1),(2); -insert into t151 values (1),(2); -insert into t152 values (1),(2); -insert into t153 values (1),(2); -insert into t154 values (1),(2); -insert into t155 values (1),(2); -insert into t156 values (1),(2); -insert into t157 values (1),(2); -insert into t158 values (1),(2); -insert into t159 values (1),(2); -insert into t160 values (1),(2); -insert into t161 values (1),(2); -insert into t162 values (1),(2); -insert into t163 values (1),(2); -insert into t164 values (1),(2); -insert into t165 values (1),(2); -insert into t166 values (1),(2); -insert into t167 values (1),(2); -insert into t168 values (1),(2); -insert into t169 values (1),(2); -insert into t170 values (1),(2); -insert into t171 values (1),(2); -insert into t172 values (1),(2); -insert into t173 values (1),(2); -insert into t174 values (1),(2); -insert into t175 values (1),(2); -insert into t176 values (1),(2); -insert into t177 values (1),(2); -insert into t178 values (1),(2); -insert into t179 values (1),(2); -insert into t180 values (1),(2); -insert into t181 values (1),(2); -insert into t182 values (1),(2); -insert into t183 values (1),(2); -insert into t184 values (1),(2); -insert into t185 values (1),(2); -insert into t186 values (1),(2); -insert into t187 values (1),(2); -insert into t188 values (1),(2); -insert into t189 values (1),(2); -insert into t190 values (1),(2); -insert into t191 values (1),(2); -insert into t192 values (1),(2); -insert into t193 values (1),(2); -insert into t194 values (1),(2); -insert into t195 values (1),(2); -insert into t196 values (1),(2); -insert into t197 values (1),(2); -insert into t198 values (1),(2); -insert into t199 values (1),(2); -insert into t200 values (1),(2); -insert into t201 values (1),(2); -insert into t202 values (1),(2); -insert into t203 values (1),(2); -insert into t204 values (1),(2); -insert into t205 values (1),(2); -insert into t206 values (1),(2); -insert into t207 values (1),(2); -insert into t208 values (1),(2); -insert into t209 values (1),(2); -insert into t210 values (1),(2); -insert into t211 values (1),(2); -insert into t212 values (1),(2); -insert into t213 values (1),(2); -insert into t214 values (1),(2); -insert into t215 values (1),(2); -insert into t216 values (1),(2); -insert into t217 values (1),(2); -insert into t218 values (1),(2); -insert into t219 values (1),(2); -insert into t220 values (1),(2); -insert into t221 values (1),(2); -insert into t222 values (1),(2); -insert into t223 values (1),(2); -insert into t224 values (1),(2); -insert into t225 values (1),(2); -insert into t226 values (1),(2); -insert into t227 values (1),(2); -insert into t228 values (1),(2); -insert into t229 values (1),(2); -insert into t230 values (1),(2); -insert into t231 values (1),(2); -insert into t232 values (1),(2); -insert into t233 values (1),(2); -insert into t234 values (1),(2); -insert into t235 values (1),(2); -insert into t236 values (1),(2); -insert into t237 values (1),(2); -insert into t238 values (1),(2); -insert into t239 values (1),(2); -insert into t240 values (1),(2); -insert into t241 values (1),(2); -insert into t242 values (1),(2); -insert into t243 values (1),(2); -insert into t244 values (1),(2); -insert into t245 values (1),(2); -insert into t246 values (1),(2); -insert into t247 values (1),(2); -insert into t248 values (1),(2); -insert into t249 values (1),(2); -insert into t250 values (1),(2); -insert into t251 values (1),(2); -insert into t252 values (1),(2); -insert into t253 values (1),(2); -insert into t254 values (1),(2); -insert into t255 values (1),(2); -insert into t256 values (1),(2); -enable_result_log; +disable_query_log; +let $1 = 257; +while ($1) +{ + eval create table t$1(a int); + eval insert into t$1 values (1),(2); + dec $1; +} +create table t00 (a int) type=MERGE UNION=(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257) INSERT_METHOD=FIRST; +enable_query_log; select count(*) from t00; select count(*) from t00; show status like "Qcache_queries_in_cache"; show status like "Qcache_hits"; delete from t256; show status like "Qcache_queries_in_cache"; -drop table t0,t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t00; +drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; diff --git a/sql/sql_class.h b/sql/sql_class.h index dcc839e13b1..c4511652b23 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -452,7 +452,6 @@ public: /* variables.transaction_isolation is reset to this after each commit */ enum_tx_isolation session_tx_isolation; char scramble[9]; - uint8 query_cache_type; // type of query cache processing bool slave_thread; bool set_query_id,locked,count_cuted_fields,some_tables_deleted; bool no_errors, allow_sum_func, password, fatal_error; From 8d816967531e4399d7ff3c5fd1b7c2234f5801b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 9 Aug 2003 01:20:02 +0200 Subject: [PATCH 018/282] BETWEEN bug fix: non-const expressions on both ends --- mysql-test/r/range.result | 2 +- sql/sql_select.cc | 69 +++++++++++++++++++++++---------------- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 4e0476fdacd..5da6f6c30e1 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -240,7 +240,7 @@ t2 range x x 5 NULL 4 Using where explain select * from t1, t1 t2 where t1.y = 2 and t2.x between t1.y-1 and t1.y+1; table type possible_keys key key_len ref rows Extra t1 ref y y 5 const 1 Using where -t2 ALL x NULL NULL NULL 9 Using where +t2 ALL x NULL NULL NULL 9 Range checked for each record (index map: 1) explain select * from t1, t1 t2 where t1.y = 2 and t2.x >= t1.y-1 and t2.x <= t1.y+1; table type possible_keys key key_len ref rows Extra t1 ref y y 5 const 1 Using where diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6675a310464..c676f389da7 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1425,28 +1425,34 @@ merge_key_fields(KEY_FIELD *start,KEY_FIELD *new_fields,KEY_FIELD *end, static void add_key_field(KEY_FIELD **key_fields,uint and_level, - Field *field,bool eq_func,Item *value, + Field *field,bool eq_func,Item **value, uint num_values, table_map usable_tables) { bool exists_optimize=0; if (!(field->flags & PART_KEY_FLAG)) { // Don't remove column IS NULL on a LEFT JOIN table - if (!eq_func || !value || value->type() != Item::NULL_ITEM || - !field->table->maybe_null || field->null_ptr) + if (!eq_func || (*value)->type() != Item::NULL_ITEM || + !field->table->maybe_null || field->null_ptr) return; // Not a key. Skip it exists_optimize=1; } else { table_map used_tables=0; - if (value && (used_tables=value->used_tables()) & - (field->table->map | RAND_TABLE_BIT)) + bool optimizable=0; + for (uint i=0; iused_tables(); + if (!((*value)->used_tables() & (field->table->map | RAND_TABLE_BIT))) + optimizable=1; + } + if (!optimizable) return; if (!(usable_tables & field->table->map)) { - if (!eq_func || !value || value->type() != Item::NULL_ITEM || - !field->table->maybe_null || field->null_ptr) + if (!eq_func || (*value)->type() != Item::NULL_ITEM || + !field->table->maybe_null || field->null_ptr) return; // Can't use left join optimize exists_optimize=1; } @@ -1457,12 +1463,6 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, field->table->keys_in_use_for_query); stat[0].keys|= possible_keys; // Add possible keys - if (!value) - { // Probably BETWEEN or IN - stat[0].const_keys |= possible_keys; - return; // Can't be used as eq key - } - /* Save the following cases: Field op constant Field LIKE constant where constant doesn't start with a wildcard @@ -1470,24 +1470,34 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, Field op formula Field IS NULL Field IS NOT NULL + Field BETWEEN ... + Field IN ... */ stat[0].key_dependent|=used_tables; - if (value->const_item()) - stat[0].const_keys |= possible_keys; + + bool is_const=1; + for (uint i=0; iconst_item(); + if (is_const) + stat[0].const_keys |= possible_keys; /* We can't always use indexes when comparing a string index to a - number. cmp_type() is checked to allow compare of dates to numbers */ + number. cmp_type() is checked to allow compare of dates to numbers + also eq_func is NEVER true when num_values > 1 + */ if (!eq_func || field->result_type() == STRING_RESULT && - value->result_type() != STRING_RESULT && - field->cmp_type() != value->result_type()) + (*value)->result_type() != STRING_RESULT && + field->cmp_type() != (*value)->result_type()) return; } } + DBUG_ASSERT(num_values == 1); + // DBUG_ASSERT(eq_func); /* QQ: Can I uncomment this ASSERT ? */ /* Store possible eq field */ (*key_fields)->field=field; (*key_fields)->eq_func=eq_func; - (*key_fields)->val=value; + (*key_fields)->val=*value; (*key_fields)->level=(*key_fields)->const_level=and_level; (*key_fields)->exists_optimize=exists_optimize; (*key_fields)++; @@ -1541,10 +1551,12 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, case Item_func::OPTIMIZE_NONE: break; case Item_func::OPTIMIZE_KEY: + // BETWEEN or IN if (cond_func->key_item()->type() == Item::FIELD_ITEM) add_key_field(key_fields,*and_level, - ((Item_field*) (cond_func->key_item()))->field, - 0,(Item*) 0,usable_tables); + ((Item_field*) (cond_func->key_item()))->field, 0, + cond_func->arguments()+1, cond_func->argument_count()-1, + usable_tables); break; case Item_func::OPTIMIZE_OP: { @@ -1556,7 +1568,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, add_key_field(key_fields,*and_level, ((Item_field*) (cond_func->arguments()[0]))->field, equal_func, - (cond_func->arguments()[1]),usable_tables); + cond_func->arguments()+1, 1, usable_tables); } if (cond_func->arguments()[1]->type() == Item::FIELD_ITEM && cond_func->functype() != Item_func::LIKE_FUNC) @@ -1564,7 +1576,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, add_key_field(key_fields,*and_level, ((Item_field*) (cond_func->arguments()[1]))->field, equal_func, - (cond_func->arguments()[0]),usable_tables); + cond_func->arguments(),1,usable_tables); } break; } @@ -1572,10 +1584,11 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, /* column_name IS [NOT] NULL */ if (cond_func->arguments()[0]->type() == Item::FIELD_ITEM) { + Item *tmp=new Item_null; add_key_field(key_fields,*and_level, ((Item_field*) (cond_func->arguments()[0]))->field, cond_func->functype() == Item_func::ISNULL_FUNC, - new Item_null, usable_tables); + &tmp, 1, usable_tables); } break; } @@ -3267,7 +3280,7 @@ change_cond_ref_to_const(I_List *save_list,Item *and_father, static void -propagate_cond_constants(I_List *save_list,COND *and_level, +propagate_cond_constants(I_List *save_list,COND *and_father, COND *cond) { if (cond->type() == Item::COND_ITEM) @@ -3293,7 +3306,7 @@ propagate_cond_constants(I_List *save_list,COND *and_level, cond_cmp->cmp_func->arguments()[1]); } } - else if (and_level != cond && !cond->marker) // In a AND group + else if (and_father != cond && !cond->marker) // In a AND group { if (cond->type() == Item::FUNC_ITEM && (((Item_func*) cond)->functype() == Item_func::EQ_FUNC || @@ -3311,7 +3324,7 @@ propagate_cond_constants(I_List *save_list,COND *and_level, func->arguments()[1]=resolve_const_item(func->arguments()[1], func->arguments()[0]); func->update_used_tables(); - change_cond_ref_to_const(save_list,and_level,and_level, + change_cond_ref_to_const(save_list,and_father,and_father, func->arguments()[0], func->arguments()[1]); } @@ -3320,7 +3333,7 @@ propagate_cond_constants(I_List *save_list,COND *and_level, func->arguments()[0]=resolve_const_item(func->arguments()[0], func->arguments()[1]); func->update_used_tables(); - change_cond_ref_to_const(save_list,and_level,and_level, + change_cond_ref_to_const(save_list,and_father,and_father, func->arguments()[1], func->arguments()[0]); } From 889618e7d4b4fb6183cd0218c0352092480f0c71 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 10 Aug 2003 05:38:08 +0600 Subject: [PATCH 019/282] BUG replace HAVE_SETFILEPOINTER with __WIN__ include/config-win.h: remove HAVE_SETFILEPOINTER mysys/my_chsize.c: replace HAVE_SETFILEPOINTER with __WIN__ move __WIN__ section to up --- include/config-win.h | 1 - mysys/my_chsize.c | 36 ++++++++++++++++++------------------ 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index cde77a6e0aa..69020636893 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -276,7 +276,6 @@ inline double ulonglong2double(ulonglong value) #define HAVE_ISAM /* We want to have support for ISAM in 4.0 */ #define HAVE_QUERY_CACHE #define SPRINTF_RETURNS_INT -#define HAVE_SETFILEPOINTER /* SetFilePointer function for huge files */ #ifdef NOT_USED #define HAVE_SNPRINTF /* Gave link error */ diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index 0840a7a69e4..5708ac5b253 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -49,24 +49,7 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) oldsize = my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE)); DBUG_PRINT("info",("old_size: %ld", (ulong) oldsize)); -#ifdef HAVE_CHSIZE - if (oldsize > newlength || filler == 0) - { - if (chsize(fd,(off_t) newlength)) - { - DBUG_PRINT("error",("errno: %d",errno)); - my_errno=errno; - if (MyFlags & MY_WME) - my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); - DBUG_RETURN(1); - } - else - { - if (filler == 0) - DBUG_RETURN(0); - } - } -#elif defined(HAVE_SETFILEPOINTER) +#ifdef __WIN__ if (oldsize > newlength) { LARGE_INTEGER new_length; @@ -84,6 +67,23 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); DBUG_RETURN(1); } +#elif define(HAVE_CHSIZE) + if (oldsize > newlength || filler == 0) + { + if (chsize(fd,(off_t) newlength)) + { + DBUG_PRINT("error",("errno: %d",errno)); + my_errno=errno; + if (MyFlags & MY_WME) + my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); + DBUG_RETURN(1); + } + else + { + if (filler == 0) + DBUG_RETURN(0); + } + } #elif defined(HAVE_FTRUNCATE) if (oldsize > newlength) { From 20901edafba09c0ef2236411b40eac06a85d2030 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 10 Aug 2003 05:14:16 +0300 Subject: [PATCH 020/282] Remove wrong bug fix when calling create_sort_index. Fix possible replication bug with LOAD DATA ... IGNORE LINES # mysql-test/r/rpl_log.result: Test of load data ... ignore # lines mysql-test/t/rpl_log.test: Test of load data ... ignore # lines sql/log_event.cc: Fix replication bug with LOAD DATA ... IGNORE LINES # (Note that the code that is probably not executed in 4.0) sql/sql_parse.cc: Indentation fix sql/sql_select.cc: Remove wrong bug fix (all tests passes) sql/sql_yacc.yy: Indentation cleanup --- mysql-test/r/rpl_log.result | 5 ++++- mysql-test/t/rpl_log.test | 7 ++++--- sql/log_event.cc | 24 ++++++++++++++++-------- sql/sql_parse.cc | 4 ++-- sql/sql_select.cc | 5 +---- sql/sql_yacc.yy | 2 +- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 640e6f02103..2798d1a9fab 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -12,7 +12,10 @@ create table t1(n int not null auto_increment primary key); insert into t1 values (NULL); drop table t1; create table t1 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1 ignore 1 lines; +select count(*) from t1; +count(*) +69 drop table t1; show binlog events; Log_name Pos Event_type Server_id Orig_log_pos Info diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test index 8cd9d21a087..ad962b585a1 100644 --- a/mysql-test/t/rpl_log.test +++ b/mysql-test/t/rpl_log.test @@ -13,7 +13,8 @@ create table t1(n int not null auto_increment primary key); insert into t1 values (NULL); drop table t1; create table t1 (word char(20) not null); -load data infile '../../std_data/words.dat' into table t1; +load data infile '../../std_data/words.dat' into table t1 ignore 1 lines; +select count(*) from t1; drop table t1; --replace_result $VERSION VERSION show binlog events; @@ -35,8 +36,8 @@ flush logs; # So, depending on a few milliseconds, we end up with 2 rotate events in the # relay log or one, which influences the output of SHOW SLAVE STATUS, making # it not predictable and causing random test failures. -# To make it predictable, we do a useless update now, but which has the interest -# of making the slave catch both rotate events. +# To make it predictable, we do a useless update now, but which has the +# interest of making the slave catch both rotate events. create table t5 (a int); drop table t5; diff --git a/sql/log_event.cc b/sql/log_event.cc index f7955be3b09..3451ffab65f 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -329,8 +329,14 @@ void Load_log_event::pack_info(String* packet) pretty_print_str(&tmp, sql_ex.line_start, sql_ex.line_start_len); } - if ((int)skip_lines > 0) - tmp.append( " IGNORE %ld LINES ", (long) skip_lines); + if ((long) skip_lines > 0) + { + char nr_buff[32], *end; + tmp.append( " IGNORE "); + end= longlong10_to_str((longlong) skip_lines, nr_buff, 10); + tmp.append(nr_buff, (uint) (end-nr_buff)); + tmp.append( " LINES"); + } if (num_fields) { @@ -1338,8 +1344,8 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) pretty_print_str(file, sql_ex.line_start, sql_ex.line_start_len); } - if ((int)skip_lines > 0) - fprintf(file, " IGNORE %ld LINES ", (long) skip_lines); + if ((long) skip_lines > 0) + fprintf(file, " IGNORE %ld LINES", (long) skip_lines); if (num_fields) { @@ -1934,20 +1940,22 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, else if (sql_ex.opt_flags & IGNORE_FLAG) handle_dup= DUP_IGNORE; else + { /* - Note that when replication is running fine, if it was DUP_ERROR on the + When replication is running fine, if it was DUP_ERROR on the master then we could choose DUP_IGNORE here, because if DUP_ERROR suceeded on master, and data is identical on the master and slave, then there should be no uniqueness errors on slave, so DUP_IGNORE is the same as DUP_ERROR. But in the unlikely case of uniqueness errors - (because the data on the master and slave happen to be different (user - error or bug), we want LOAD DATA to print an error message on the - slave to discover the problem. + (because the data on the master and slave happen to be different + (user error or bug), we want LOAD DATA to print an error message on + the slave to discover the problem. If reading from net (a 3.23 master), mysql_load() will change this to DUP_IGNORE. */ handle_dup= DUP_ERROR; + } sql_exchange ex((char*)fname, sql_ex.opt_flags & DUMPFILE_FLAG); String field_term(sql_ex.field_term,sql_ex.field_term_len); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 70c0f772d7d..f0e845e6f36 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -3579,8 +3579,8 @@ bool reload_acl_and_cache(THD *thd, ulong options, TABLE_LIST *tables) if (options & REFRESH_LOG) { /* - Flush the normal query log, the update log, the binary log, the slow query - log, and the relay log (if it exists). + Flush the normal query log, the update log, the binary log, + the slow query log, and the relay log (if it exists). */ mysql_log.new_file(1); mysql_update_log.new_file(1); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6675a310464..c72d450ae4a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -972,10 +972,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List &fields,COND *conds, group ? group : order, select_limit, thd->select_limit)) - { - if (!join.join_tab[join.const_tables].select->quick) - goto err; - } + goto err; } join.having=having; // Actually a parameter thd->proc_info="Sending data"; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index b07dca91a20..03837300904 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2024,7 +2024,7 @@ simple_expr: { LEX *lex=Lex; $$= new Item_func_week($3,new Item_int((char*) "0", - lex->thd->variables.default_week_format,1)); + lex->thd->variables.default_week_format,1)); } | WEEK_SYM '(' expr ',' expr ')' { $$= new Item_func_week($3,$5); } From 68f8339158d8b54111bf179fb08040b51b0778c0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 11 Aug 2003 20:48:51 +0300 Subject: [PATCH 021/282] fixed collation of Item_cache family (BUG#951) mysql-test/r/subselect.result: test of collation mysql-test/t/subselect.test: test of collation sql/item.cc: coping collation in the cache sql/item.h: coping collation in the cache --- mysql-test/r/subselect.result | 7 +++++++ mysql-test/t/subselect.test | 11 +++++++++++ sql/item.cc | 2 +- sql/item.h | 2 ++ 4 files changed, 21 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 1db31881607..94d3258aef2 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1251,3 +1251,10 @@ a 2 10 drop table t1,t2; +CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, +s2 CHAR(5) COLLATE latin1_swedish_ci); +INSERT INTO t1 VALUES ('z','?'); +select * from t1 where s1 > (select max(s2) from t1); +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>' +select * from t1 where s1 > any (select max(s2) from t1); +drop table t1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 28408bbf365..1359e1b5dda 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -853,3 +853,14 @@ insert into t3 values (1),(2),(10),(50); select a from t3 where t3.a in (select a from t1 where a <= 3 union select * from t2 where a <= 30); drop table t1,t2; +# +# collation test +# +CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, + s2 CHAR(5) COLLATE latin1_swedish_ci); +INSERT INTO t1 VALUES ('z','?'); +-- error 1265 +select * from t1 where s1 > (select max(s2) from t1); +-- error 1265 +select * from t1 where s1 > any (select max(s2) from t1); +drop table t1; diff --git a/sql/item.cc b/sql/item.cc index 17b0519b61c..7c9579416db 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1704,7 +1704,7 @@ void Item_cache_str::store(Item *item) str_value.copy(*value); value= &str_value; } - + collation.set(item->collation); } double Item_cache_str::val() { diff --git a/sql/item.h b/sql/item.h index 3412b43da44..9355b43f538 100644 --- a/sql/item.h +++ b/sql/item.h @@ -852,6 +852,7 @@ public: { value= item->val_int_result(); null_value= item->null_value; + collation.set(item->collation); } double val() { return (double) value; } longlong val_int() { return value; } @@ -869,6 +870,7 @@ public: { value= item->val_result(); null_value= item->null_value; + collation.set(item->collation); } double val() { return value; } longlong val_int() { return (longlong) (value+(value > 0 ? 0.5 : -0.5)); } From b0700aff80b12ba2771c51200d009c27928fd9ea Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Aug 2003 13:49:11 +0200 Subject: [PATCH 022/282] - added option "--pull" to be able to update the BK repositories before starting the bootstrap --- Build-tools/Bootstrap | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 33eca958ae0..747d73398ab 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -38,6 +38,7 @@ $opt_export_only= undef; $opt_help= $opt_verbose= 0; $opt_log= undef; $opt_mail= ""; +$opt_pull= undef; $opt_revision= undef; $opt_suffix= ""; $opt_test= undef; @@ -58,6 +59,7 @@ GetOptions( "help|h", "log|l:s", "mail|m=s", + "pull|p", "revision|r=s", "skip-check|s", "skip-manual", @@ -110,6 +112,23 @@ if (($opt_directory ne ".") && (!-d $opt_directory && !$opt_dry_run)) &logger("Logging to $LOGFILE") if (defined $opt_log); +# +# Pull recent changes first +# +if ($opt_pull) +{ + &logger("Updating BK tree $REPO to latest ChangeSet first"); + $command= "cd $REPO; bk pull; cd .."; + &run_command($command, "Could not update $REPO!"); + + unless ($opt_skip_manual) + { + &logger("Updating manual tree in $opt_docdir"); + $command= "cd $opt_docdir; bk pull; cd .."; + &run_command($command, "Could not update $opt_docdir!"); + } +} + # # Use a temporary name until we know the version number # @@ -253,7 +272,7 @@ if (defined $opt_changelog) # # Add the latest manual from the mysqldoc tree # -if (!$opt_skip_manual) +unless ($opt_skip_manual) { $msg= "Adding manual.texi"; &logger($msg); @@ -378,6 +397,7 @@ Options: include a log file snippet, if logging is enabled) Note that the \@-Sign needs to be quoted! Example: --mail=user\\\@domain.com +-p, --pull Update the source BK trees before building -r, --revision= Export the tree as of revision (default is up to the latest revision) -s, --skip-check Skip checking the distribution with "make distcheck" From 8e6ff087df86b76a50cb35222c7a27871eb784f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Aug 2003 15:28:36 +0200 Subject: [PATCH 023/282] snprintf compatibility fix --- myisam/ft_dump.c | 4 ++++ sql/field.cc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/myisam/ft_dump.c b/myisam/ft_dump.c index d95e719e234..69fef529fa9 100644 --- a/myisam/ft_dump.c +++ b/myisam/ft_dump.c @@ -130,7 +130,11 @@ int main(int argc,char *argv[]) #error #endif +#ifdef HAVE_SNPRINTF snprintf(buf,MAX_LEN,"%.*s",(int) keylen,info->lastkey+1); +#else + sprintf(buf,"%.*s",(int) keylen,info->lastkey+1); +#endif casedn_str(buf); total++; lengths[keylen]++; diff --git a/sql/field.cc b/sql/field.cc index 9babe069300..e56d53b1bda 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -742,7 +742,7 @@ void Field_decimal::store(double nr) char buff[320]; fyllchar = zerofill ? (char) '0' : (char) ' '; -#ifdef HAVE_SNPRINTF_ +#ifdef HAVE_SNPRINTF buff[sizeof(buff)-1]=0; // Safety snprintf(buff,sizeof(buff)-1, "%.*f",(int) dec,nr); #else From f4e26a8bad225fd6a3262bfb600efc9db20484e6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Aug 2003 15:30:20 +0200 Subject: [PATCH 024/282] MyISAM was erroneously using max_ref_length when estimating min_pack_length. --- myisam/mi_packrec.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/myisam/mi_packrec.c b/myisam/mi_packrec.c index 66cfd169026..7557bb8749f 100644 --- a/myisam/mi_packrec.c +++ b/myisam/mi_packrec.c @@ -165,7 +165,9 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) diff_length=(int) rec_reflength - (int) share->base.rec_reflength; if (fix_keys) share->rec_reflength=rec_reflength; - share->base.min_block_length=share->min_pack_length+share->pack.ref_length; + share->base.min_block_length=share->min_pack_length+1; + if (share->min_pack_length > 254) + share->base.min_block_length+=2; if (!(share->decode_trees=(MI_DECODE_TREE*) my_malloc((uint) (trees*sizeof(MI_DECODE_TREE)+ From b7efbc3fd4a73e88b5a22bef30eb46ca0d61541d Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Aug 2003 15:56:55 +0200 Subject: [PATCH 025/282] myisamchk - don't mark table as crashed if --sort-records= failed because of unappropriate key or read-only table --- myisam/myisamchk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 1a27e9debe8..4fadfd2fc5d 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -1403,20 +1403,20 @@ static int mi_sort_records(MI_CHECK *param, mi_check_print_error(param,"Can't sort table '%s' on key %d; No such key", name,sort_key+1); param->error_printed=0; - DBUG_RETURN(-1); + DBUG_RETURN(0); /* Nothing to do */ } if (keyinfo->flag & HA_FULLTEXT) { mi_check_print_error(param,"Can't sort table '%s' on FULLTEXT key %d", name,sort_key+1); param->error_printed=0; - DBUG_RETURN(-1); + DBUG_RETURN(0); /* Nothing to do */ } if (share->data_file_type == COMPRESSED_RECORD) { mi_check_print_error(param,"Can't sort read-only table '%s'", name); param->error_printed=0; - DBUG_RETURN(-1); + DBUG_RETURN(0); /* Nothing to do */ } if (!(param->testflag & T_SILENT)) { From 7e7edcf9b6486caef09dcc3bf50a2e2ca4bf0f79 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Aug 2003 19:21:38 +0200 Subject: [PATCH 026/282] isam SEARCH_LAST bug fixed --- isam/_search.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/isam/_search.c b/isam/_search.c index 93a08ea2b0d..c005e9ddb69 100644 --- a/isam/_search.c +++ b/isam/_search.c @@ -119,7 +119,7 @@ int _nisam_search(register N_INFO *info, register N_KEYDEF *keyinfo, uchar *key, { keypos=_nisam_get_last_key(info,keyinfo,buff,lastkey,keypos); if ((nextflag & SEARCH_LAST) && - _nisam_key_cmp(keyinfo->seg, info->lastkey, key, key_len, SEARCH_FIND)) + _nisam_key_cmp(keyinfo->seg, lastkey, key, key_len, SEARCH_FIND)) { my_errno=HA_ERR_KEY_NOT_FOUND; /* Didn't find key */ goto err; From ff9f600f7d777e1e6fe9160109d3a5b37752832a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Aug 2003 23:45:04 +0300 Subject: [PATCH 027/282] fixed query cache intercommunication with innodb engine mysql-test/r/innodb_cache.result: new results --- mysql-test/r/innodb_cache.result | 8 +++--- sql/sql_cache.cc | 42 ++++++++++++++++++++++++++++++++ sql/sql_cache.h | 2 ++ 3 files changed, 48 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/innodb_cache.result b/mysql-test/r/innodb_cache.result index c422dca36f1..7706e60d143 100644 --- a/mysql-test/r/innodb_cache.result +++ b/mysql-test/r/innodb_cache.result @@ -10,7 +10,7 @@ a 3 show status like "Qcache_queries_in_cache"; Variable_name Value -Qcache_queries_in_cache 1 +Qcache_queries_in_cache 0 drop table t1; commit; set autocommit=1; @@ -24,7 +24,7 @@ a 3 show status like "Qcache_queries_in_cache"; Variable_name Value -Qcache_queries_in_cache 1 +Qcache_queries_in_cache 0 drop table t1; commit; create table t1 (a int not null) type=innodb; @@ -90,14 +90,14 @@ a 2 show status like "Qcache_queries_in_cache"; Variable_name Value -Qcache_queries_in_cache 3 +Qcache_queries_in_cache 1 show status like "Qcache_hits"; Variable_name Value Qcache_hits 4 commit; show status like "Qcache_queries_in_cache"; Variable_name Value -Qcache_queries_in_cache 3 +Qcache_queries_in_cache 1 drop table if exists t1; CREATE TABLE t1 (id int(11) NOT NULL auto_increment, PRIMARY KEY (id)) TYPE=InnoDB; select count(*) from t1; diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index ac6471e794c..bae2718c8b6 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -769,9 +769,18 @@ void Query_cache::store_query(THD *thd, TABLE_LIST *tables_used) STRUCT_LOCK(&structure_guard_mutex); if (query_cache_size == 0) + { + STRUCT_UNLOCK(&structure_guard_mutex); DBUG_VOID_RETURN; + } DUMP(this); + if (ask_handler_allowance(thd, tables_used)) + { + STRUCT_UNLOCK(&structure_guard_mutex); + DBUG_VOID_RETURN; + } + /* Key is query + database + flag */ if (thd->db_length) { @@ -2548,6 +2557,39 @@ TABLE_COUNTER_TYPE Query_cache::is_cacheable(THD *thd, uint32 query_len, DBUG_RETURN(0); } +/* + Check handler allowence to cache query with this tables + + SYNOPSYS + Query_cache::ask_handler_allowance() + thd - thread handlers + tables_used - tables list used in query + + RETURN + 0 - caching allowed + 1 - caching disallowed +*/ +my_bool Query_cache::ask_handler_allowance(THD *thd, + TABLE_LIST *tables_used) +{ + DBUG_ENTER("Query_cache::is_cacheable"); + + for (; tables_used; tables_used= tables_used->next) + { + TABLE *table= tables_used->table; + if (!handler::caching_allowed(thd, table->table_cache_key, + table->key_length, + table->file->table_cache_type())) + { + DBUG_PRINT("qcache", ("Handler does not allow caching for %s.%s", + tables_used->db, tables_used->alias)); + thd->lex.safe_to_cache_query= 0; // Don't try to cache this + DBUG_RETURN(1); + } + } + DBUG_RETURN(0); +} + /***************************************************************************** Packing diff --git a/sql/sql_cache.h b/sql/sql_cache.h index eea542e9d06..af23b97aade 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -345,6 +345,8 @@ protected: TABLE_COUNTER_TYPE is_cacheable(THD *thd, uint32 query_len, char *query, LEX *lex, TABLE_LIST *tables_used, uint8 *tables_type); + + static my_bool ask_handler_allowance(THD *thd, TABLE_LIST *tables_used); public: Query_cache(ulong query_cache_limit = ULONG_MAX, From 965050afc9340a108a389ada8e3ecea948da1302 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 12 Aug 2003 23:21:21 +0200 Subject: [PATCH 028/282] - enabled embedded server in the binary distributions by default (Do-compile) - added mysql.info to the binary distribution files (BUG#1019) - heavily reworked the Do-rpm script to be more in line with Do-pkg - create a "docs" subdirectory in the binary distribution and moved the manual, ChangeLog and mysql.info file into it to unclutter the top directory Build-tools/Do-compile: - enable compiling with the embedded server by default (as requested by BrianA) - disable it with the "--disable-embedded" compile option. Build-tools/Do-rpm: - replaced the original Shell script with a Perl script, similar to Do-pkg. Some more work remains to be done (copying the resulting packages, enable using different compile flags and compilers). scripts/make_binary_distribution.sh: - move some docs into a subdirectory "docs" to not clutter the top directory with too many files. - added mysql.info info file to the docs dir (BUG#1019) --- Build-tools/Do-compile | 6 +- Build-tools/Do-rpm | 378 +++++++++++----------------- scripts/make_binary_distribution.sh | 19 +- 3 files changed, 163 insertions(+), 240 deletions(-) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index 45037c2f3f0..6cf577162ed 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -8,7 +8,7 @@ use Getopt::Long; $opt_distribution=$opt_user=$opt_config_env=""; $opt_dbd_options=$opt_perl_options=$opt_config_options=$opt_make_options=$opt_suffix=""; $opt_tmp=$opt_version_suffix=""; -$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=0; +$opt_help=$opt_delete=$opt_debug=$opt_stage=$opt_no_test=$opt_no_perl=$opt_with_low_memory=$opt_fast_benchmark=$opt_static_client=$opt_static_server=$opt_static_perl=$opt_sur=$opt_with_small_disk=$opt_local_perl=$opt_tcpip=$opt_build_thread=$opt_use_old_distribution=$opt_enable_shared=$opt_no_crash_me=$opt_no_strip=$opt_with_debug=$opt_no_benchmark=$opt_no_mysqltest=$opt_without_embedded=0; $opt_innodb=$opt_bdb=$opt_raid=$opt_libwrap=0; GetOptions( @@ -230,6 +230,7 @@ if ($opt_stage <= 1) $opt_config_options.= " --with-low-memory" if ($opt_with_low_memory); $opt_config_options.= " --with-mysqld-ldflags=-all-static" if ($opt_static_server); $opt_config_options.= " --with-raid" if ($opt_raid); + $opt_config_options.= " --with-embedded-server" unless ($opt_without_embedded); # Only enable InnoDB when requested (required to be able to # build the "Classic" packages that do not include InnoDB) @@ -551,6 +552,9 @@ non-standard location overriding default. --with-small-disk Clean up the build environment before testing the binary distribution (to save disk space) + +--without-embedded +Don't compile the embedded server. EOF exit 1; } diff --git a/Build-tools/Do-rpm b/Build-tools/Do-rpm index 6d107bc2413..77f87cd0358 100755 --- a/Build-tools/Do-rpm +++ b/Build-tools/Do-rpm @@ -1,259 +1,167 @@ -#!/bin/bash +#!/usr/bin/perl -w +# +# Do-rpm - compile RPM packages out of a source tarball and copy the +# resulting RPM packages into the current directory. +# +# The script currently assumes the following environment (which should exist +# like that, if the Do-compile script was used to build the binary +# distribution) +# +# - there must be a source distribution (mysql-.tar.gz) +# in the current directory +# - there must be a spec file (mysql-.spec) in the directory +# $HOME//mysql-/support-files/ +# +# Use the "--help" option for more info! +# +# written by Lenz Grimmer +# -#helper functions +use Getopt::Long; +Getopt::Long::Configure ("bundling"); -function copy_to_bmachine +$opt_dry_run= undef; +$opt_help= undef; +$opt_log= undef; +$opt_mail= ""; +$opt_verbose= undef; +$opt_version= undef; + +GetOptions( + "dry-run", + "help|h", + "log|l:s", + "mail|m=s", + "verbose|v", + "version=s", +) || &print_help; + +# Include helper functions +chomp($PWD= `pwd`); +$LOGGER= "$PWD/logger.pm"; +if (-f "$LOGGER") { - if [ x$local_build = x1 ]; then - rm -f $2 - cp $1 $2 - else - scp $1 $owner@$bmachine:$2 - fi + do "$LOGGER"; +} +else +{ + die "ERROR: $LOGGER cannot be found!\n"; } -function copy_from_bmachine +# +# Override predefined Log file name +# +if (defined $opt_log) { - if [ x$local_build = x1 ]; then - rm -f $2 - cp $1 $2 - else - scp $owner@$bmachine:$1 $2 - fi + if ($opt_log ne "") + { + if ($opt_log =~ /^\/.*/) + { + $LOGFILE= $opt_log; + } + else + { + $LOGFILE= $PWD . "/" . $opt_log; + } + } } -function run_command +&print_help("") if ($opt_help || !$opt_version); + +# +# Newer RPM version ship with a separate tool to build RPMs +# +if (-x "/usr/bin/rpmbuild") { - if [ x$local_build = x1 ]; then - bash $1 - else - cat $1 | ssh $owner@$bmachine bash - fi + $RPM= "/usr/bin/rpmbuild"; +} +else +{ + $RPM= "/bin/rpm"; } -#Supply defaults +foreach $DIR ("/usr/src/packages", "/usr/src/redhat") +{ + if (-d $DIR) + { + $TOPDIR= $DIR; + last; + } +} -# We built on one of two machines -bmachine=work -smachine=work -owner=my +$SPECDIR= $TOPDIR . "/SPECS"; +$SOURCEDIR= $TOPDIR . "/SOURCES"; -# Hard path!! -bpath=`/bin/pwd` +$VERSION= $opt_version; +($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION); +chomp($HOST= `hostname`); +$HOST=~ /^([^.-]*)/; +$HOST= $1; +$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log"; +$SOURCEFILE= "mysql-$VERSION.tar.gz"; +$SPECFILE= "$PWD/$HOST/mysql-$VERSION/support-files/mysql-$VERSION.spec"; -for d in /usr/src/redhat /usr/src/packages ; do -if test -d "$d" -then - rpmdir=$d -fi -done +&logger("Starting RPM build of MySQL-$VERSION on $HOST"); -if test -z "$rpmdir" -then - echo "Could not find suitable rpmdir on this system" - exit 1 -fi - +foreach $file ($SOURCEFILE, $SPECFILE) +{ + &abort("Unable to find $file!") unless (-f "$file"); +} -logdir="$bpath/Logs" +# +# Install source and spec file +# +&logger("Copying SOURCE and SPEC file to build directories."); +$command= "cp"; +$command.= " -v" if ($opt_verbose); +$command.= " $SOURCEFILE $SOURCEDIR"; +&run_command($command, "Unable to copy $SOURCEFILE to $SOURCEDIR!"); +$command= "cp"; +$command.= " -v" if ($opt_verbose); +$command.= " $SPECFILE $SPECDIR"; +&run_command($command, "Unable to copy $SPECFILE to $SPECDIR!"); -###### Perl STUFF ##### +# +# Build the RPMs +# +$command= "$RPM"; +$command.=" -v" if ($opt_verbose); +$command.=" -ba --clean $SPECDIR/$SPECFILE"; +&logger("Builing RPM."); +&run_command($command, "Unable to build RPM!"); -# Perl version numbers. Should be autodetected from the files in the -# Perl-mysql-modules/ directory. -DBI_VERSION="1.14" -DATA_SHOWTABLE_VERSION="3.3" -DBD_MYSQL_VERSION="1.2215" -MAKERPM="$rpmdir/SOURCES/makerpm.pl" +&logger("SUCCESS: RPM files successfully created.") if (!$opt_dry_run); +exit 0; -####################### -AM_MAKEFLAGS="-j 2" +sub print_help +{ + my $message= $_[0]; + if ($message ne "") + { + print "\n"; + print "ERROR: $message\n"; + } + print < --version= -while test $# -gt 0; do - case "$1" in - --rpmdir=*) - rpmdir=`echo $1 | sed -e "s;--rpmdir=;;"` - ;; - --smachine=*) - smachine=`echo $1 | sed -e "s;--smachine=;;"` - ;; - --bmachine=*) - bmachine=`echo $1 | sed -e "s;--bmachine=;;"` - ;; - --owner=*) - owner=`echo $1 | sed -e "s;--owner=;;"` - ;; - --tarball=*) - tarball=`echo $1 | sed -e "s;--tarball=;;"` - ;; - --logdir=*) - logdir=`echo $1 | sed -e "s;--logdir=;;"` - ;; - --local ) - local_build=1 - ;; - --skip-perl ) - skip_perl=1 - ;; - * ) break ;; - esac - shift -done +Creates a binary RPM package out of a MySQL source distribution and copy the +resulting RPMs into the current directory. -echo "Removing old MySQL packages" -rm -f $bpath/NEW-RPMS/MySQL-*rpm +Options: -if [ ! -d "$logdir" ]; then - echo "$logdir does not exist, creating" - mkdir -p $logdir -fi + --dry-run Dry run without executing +-h, --help Print this help +-l, --log[=] Write a log file [to ] + (default is "$LOGFILE") +-m, --mail=
Mail a failure report to the given address + (and include a log file snippet, if logging + is enabled) + Note that the \@-Sign needs to be quoted! + Example: --mail=user\\\@domain.com + --version= The MySQL version number (e.g. 4.0.11-gamma) +-v, --verbose Verbose execution -if [ ! -f "$tarball" ]; then - echo "Tarball file $tarball does not exist, please make one first" - exit 1 -fi - -log=$logdir/Log-RPM-`date +%y%m%d-%H%M` - -echo "Building RPM for MySQL version $VER on $bmachine" -echo "Details in $log" - -( -set -x -# remove old stuff -rm -rf $rpmdir/BUILD/mysql-* -rm -f $rpmdir/SOURCES/mysql-* -rm -f $rpmdir/SRPMS/MySQL-* -rm -f $rpmdir/SPECS/mysql-* -rm -rf /var/tmp/mysql - -# Copy MySQL source and spec files - -#Sasha: I left the scp stuff commented out instead of deleted to make it -#easy to revert in a hurry, if there is a need. Once everything is tested -#and works perfectly, the scp stuff should be deleted to avoid confusion - -#scp $bpath/mysql-$VER.tar.gz $owner@$bmachine:$rpmdir/SOURCES -copy_to_bmachine $tarball $rpmdir/SOURCES -#scp $bpath/Docs/Images/mysql-logo.gif $owner@$bmachine:$rpmdir/SOURCES/mysql.gif -copy_to_bmachine $bpath/Docs/Images/mysql-logo.gif $rpmdir/SOURCES/mysql.gif -#scp $bpath/support-files/mysql-$VER.spec $owner@$bmachine:$rpmdir/SPECS -copy_to_bmachine $bpath/support-files/mysql-$VER.spec $rpmdir/SPECS - -# Copy perl things. Has to be uncompressed since Compress.pm is not -# installed yet. Set CEXT to .gz when we support compression. -CEXT= -#scp $bpath/Perl-mysql-modules/To-SOURCES/* $owner@$bmachine:$rpmdir/SOURCES - -# This had to be installed on the target machince! -# http://www.perl.com/CPAN/modules/by-module/Archive/Archive-Tar-0.21.tar.gz -# cd /usr/lib/perl5/site_perl/5.005; ln -s ../* .; rm -f 5.005 - -TMP_SCRIPT_MYSQL=00-temp-for-do-rpm.$$ -cat > $logdir/$TMP_SCRIPT_MYSQL < $logdir/$TMP_SCRIPT_PERL < $log 2>&1 +EOF + exit 1; +} diff --git a/scripts/make_binary_distribution.sh b/scripts/make_binary_distribution.sh index 73aa95a1100..8735fc800ce 100644 --- a/scripts/make_binary_distribution.sh +++ b/scripts/make_binary_distribution.sh @@ -61,7 +61,7 @@ case $system in esac -mkdir $BASE $BASE/bin \ +mkdir $BASE $BASE/bin $BASE/docs \ $BASE/include $BASE/lib $BASE/support-files $BASE/share $BASE/scripts \ $BASE/mysql-test $BASE/mysql-test/t $BASE/mysql-test/r \ $BASE/mysql-test/include $BASE/mysql-test/std_data @@ -73,9 +73,20 @@ if [ $BASE_SYSTEM != "netware" ] ; then chmod o-rwx $BASE/data $BASE/data/* fi -for i in ChangeLog COPYING COPYING.LIB README Docs/INSTALL-BINARY \ - MySQLEULA.txt Docs/manual.html Docs/manual.txt Docs/manual_toc.html \ - LICENSE.doc README.NW Docs/mysqlbug.txt +for i in ChangeLog \ + Docs/manual.html \ + Docs/manual.txt \ + Docs/manual_toc.html \ + Docs/mysql.info +do + if [ -f $i ] + then + $CP $i $BASE/docs + fi +done + +for i in COPYING COPYING.LIB README Docs/INSTALL-BINARY \ + MySQLEULA.txt LICENSE.doc README.NW do if [ -f $i ] then From 8712fee26ebce21b986b08c28666aedd51dd961b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 03:22:34 +0600 Subject: [PATCH 029/282] nothing interesting --- mysys/my_chsize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index 5708ac5b253..e8c3c056029 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -67,7 +67,7 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); DBUG_RETURN(1); } -#elif define(HAVE_CHSIZE) +#elif defined(HAVE_CHSIZE) if (oldsize > newlength || filler == 0) { if (chsize(fd,(off_t) newlength)) From 7d6f4747774ba01c89e98277646bb976a09375c4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 02:13:45 +0200 Subject: [PATCH 030/282] Bootstrap: Corrections to Bootstrap for --win-dist Build-tools/Bootstrap: Corrections to for --win-dist BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + Build-tools/Bootstrap | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 49f98d092bb..3ee214e6760 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -22,6 +22,7 @@ gluh@gluh.mysql.r18.ru greg@gcw.ath.cx greg@mysql.com guilhem@mysql.com +gweir@build.mysql.com gweir@work.mysql.com heikki@donna.mysql.fi heikki@hundin.mysql.fi diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 747d73398ab..877978e0b93 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -329,7 +329,7 @@ $command= "make dist"; if ($opt_win_dist) { &logger ("Creating Windows source package"); - $command= "./scripts/make_win_src_distibution"; + $command= "$target_dir/scripts/make_win_src_distribution"; &run_command($command, "make_win_src_distribution failed!"); } From 791581016cf3fbaa7df0dfbfd3ae4ab7e8972df9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 04:52:03 +0200 Subject: [PATCH 031/282] make_win_src_distribution.sh: Copy some previously missed files scripts/make_win_src_distribution.sh: Copy some previously missed files --- scripts/make_win_src_distribution.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 8f8ee344e93..fc07068d735 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -249,11 +249,12 @@ touch $BASE/innobase/ib_config.h # cd $SOURCE -for i in COPYING ChangeLog README \ +for i in COPYING COPYING.LIB ChangeLog README \ INSTALL-SOURCE INSTALL-WIN \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ - Docs/mysqld_error.txt Docs/INSTALL-BINARY + Docs/manual.txt Docs/mysqld_error.txt \ + Docs/INSTALL-BINARY do print_debug "Copying file '$i'" @@ -263,6 +264,20 @@ do fi done +# +# Raw dirs from source tree +# + +for i in Docs/Flags scripts sql-bench SSL \ + tests tools +do + print_debug "Copying directory '$i'" + if [ -d $i ] + then + $CP -R $i $BASE/$i + fi +done + # # Fix some windows files # From c32ebf3a86bae7d1cc1a35da7fc6c4487b84d32f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 07:12:08 +0200 Subject: [PATCH 032/282] Fixed typo in the Boostrap strip Build-tools/Bootstrap: - fixed typo --- Build-tools/Bootstrap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 747d73398ab..c1838e1aefc 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -329,7 +329,7 @@ $command= "make dist"; if ($opt_win_dist) { &logger ("Creating Windows source package"); - $command= "./scripts/make_win_src_distibution"; + $command= "./scripts/make_win_src_distribution"; &run_command($command, "make_win_src_distribution failed!"); } From 78b59b190eb3a18b407c388209f66363b5b227e7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 16:36:01 +0200 Subject: [PATCH 033/282] make_win_src_distribution.sh: Clean up script, add needed modifications to generate a complete 4.0 Windows source package scripts/make_win_src_distribution.sh: Clean up script, add needed modifications to generate a complete 4.0 Windows source package --- scripts/make_win_src_distribution.sh | 82 ++++++++++++++++------------ 1 file changed, 46 insertions(+), 36 deletions(-) diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index fc07068d735..f0cc70c10c5 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -98,15 +98,29 @@ parse_arguments "$@" for i in $TMP $TMPDIR $TEMPDIR $TEMP /tmp do - if [ "$i" ]; then + if [ "$i" ]; then print_debug "Setting TMP to '$i'" - TMP=$i + TMP=$i break fi done - + # +# Convert argument file from unix to DOS text +# + +unix_to_dos() +{ + for arg do + print_debug "Replacing LF -> CRLF from '$arg'" + + sed -e 's/$/\r/' $arg > $arg.tmp + rm -f $arg + mv $arg.tmp $arg + done +} + # # Create a tmp dest directory to copy files @@ -121,16 +135,11 @@ fi $CP -r $SOURCE/VC++Files $BASE ( -find $BASE \( -name "*.dsp" -o -name "*.dsw" \) -and -not -path \*SCCS\* -print +find $BASE \( -name "*.dsp" -o -name "*.dsw" -o -name "*.txt" \) -and -not -path \*SCCS\* -print )|( - while read v + while read v do - print_debug "Replacing LF -> CRLF from '$v'" - - # ^M -> type CTRL V + CTRL M - cat $v | sed 's/ //' | sed 's/$/ /' > $v.tmp - rm $v - mv $v.tmp $v + unix_to_dos $v done ) @@ -147,7 +156,7 @@ rm -r -f "$BASE/share/Makefile.am" # Clean up if we did this from a bk tree # -if [ -d $BASE/SCCS ] +if [ -d $BASE/SCCS ] then find $BASE/ -type d -name SCCS -printf " \"%p\"" | xargs rm -r -f fi @@ -169,9 +178,9 @@ copy_dir_files() mkdir $BASE/$arg fi for i in *.c *.cpp *.h *.ih *.i *.ic *.asm *.def \ - README INSTALL* LICENSE - do - if [ -f $i ] + README INSTALL* LICENSE + do + if [ -f $i ] then $CP $SOURCE/$arg/$i $BASE/$arg/$i fi @@ -195,21 +204,19 @@ copy_dir_dirs() { for arg do - basedir=$arg - - if [ ! -d $BASE/$arg ]; then - mkdir $BASE/$arg - fi - - copy_dir_files $arg - - cd $SOURCE/$arg/ - for i in * - do - if [ -d $SOURCE/$basedir/$i ] && [ "$i" != "SCCS" ]; then - copy_dir_files $basedir/$i - fi - done + cd $SOURCE + ( + find $arg -type d \ + -and -not -path \*SCCS\* \ + -and -not -path \*.deps\* \ + -and -not -path \*autom4te.cache -print + )|( + while read v + do + copy_dir_files $v + done + ) + done } @@ -254,11 +261,11 @@ for i in COPYING COPYING.LIB ChangeLog README \ INSTALL-WIN-SOURCE \ Docs/manual_toc.html Docs/manual.html \ Docs/manual.txt Docs/mysqld_error.txt \ - Docs/INSTALL-BINARY - + Docs/INSTALL-BINARY + do print_debug "Copying file '$i'" - if [ -f $i ] + if [ -f $i ] then $CP $i $BASE/$i fi @@ -284,11 +291,14 @@ done ./extra/replace std:: "" -- $BASE/sql/sql_yacc.cpp +unix_to_dos $BASE/README +mv $BASE/README $BASE/README.txt + # # Initialize the initial data directory # -if [ -f scripts/mysql_install_db ]; then +if [ -f scripts/mysql_install_db ]; then print_debug "Initializing the 'data' directory" scripts/mysql_install_db --no-defaults --windows --datadir=$BASE/data fi @@ -349,9 +359,9 @@ which_1 () # Create the result zip/tar file # -set_tarzip_options() +set_tarzip_options() { - for arg + for arg do if [ "$arg" = "tar" ]; then ZIPFILE1=gnutar From 88977ce1dc83a5a4f4e98925346f337235b935f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 16:45:28 +0200 Subject: [PATCH 034/282] make_win_src_distribution.sh: Adding *.txt here didn't work well-- infolist.txt is in a path containing spaces scripts/make_win_src_distribution.sh: Adding *.txt here didn't work well-- infolist.txt is in a path containing spaces --- scripts/make_win_src_distribution.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index f0cc70c10c5..89454345c7b 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -135,7 +135,7 @@ fi $CP -r $SOURCE/VC++Files $BASE ( -find $BASE \( -name "*.dsp" -o -name "*.dsw" -o -name "*.txt" \) -and -not -path \*SCCS\* -print +find $BASE \( -name "*.dsp" -o -name "*.dsw" \) -and -not -path \*SCCS\* -print )|( while read v do From e4e8a2f3cc3b4869007ec1447afd3a5364a3723b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 17:00:22 +0200 Subject: [PATCH 035/282] make_win_src_distribution.sh: 'tools' contains intermediate files scripts/make_win_src_distribution.sh: 'tools' contains intermediate files --- scripts/make_win_src_distribution.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 89454345c7b..1946da16186 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -227,7 +227,7 @@ copy_dir_dirs() { for i in client dbug extra heap include isam \ libmysql libmysqld merge myisam \ myisammrg mysys regex sql strings \ - vio zlib + tools vio zlib do copy_dir_files $i done @@ -276,7 +276,7 @@ done # for i in Docs/Flags scripts sql-bench SSL \ - tests tools + tests do print_debug "Copying directory '$i'" if [ -d $i ] From 9ac61d15faf874589bd01ae9fa8d1854f6dc6621 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 13 Aug 2003 19:32:34 +0200 Subject: [PATCH 036/282] make_win_src_distribution.sh: Add --zip option for finer grain control over what package formats are created Bootstrap: Create both Windows source packages Build-tools/Bootstrap: Create both Windows source packages scripts/make_win_src_distribution.sh: Add --zip option for finer grain control over what package formats are created --- Build-tools/Bootstrap | 2 +- scripts/make_win_src_distribution.sh | 79 ++++++++++++++++++---------- 2 files changed, 53 insertions(+), 28 deletions(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index c1838e1aefc..1facf7b5f0d 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -329,7 +329,7 @@ $command= "make dist"; if ($opt_win_dist) { &logger ("Creating Windows source package"); - $command= "./scripts/make_win_src_distribution"; + $command= "./scripts/make_win_src_distribution --tar --zip"; &run_command($command, "make_win_src_distribution failed!"); } diff --git a/scripts/make_win_src_distribution.sh b/scripts/make_win_src_distribution.sh index 1946da16186..9b310722886 100755 --- a/scripts/make_win_src_distribution.sh +++ b/scripts/make_win_src_distribution.sh @@ -14,6 +14,7 @@ SILENT=0 SUFFIX="" DIRNAME="" OUTTAR=0 +OUTZIP=0 # # This script must run from MySQL top directory @@ -62,7 +63,8 @@ show_usage() echo " --suffix Suffix name for the package" echo " --dirname Directory name to copy files (intermediate)" echo " --silent Do not list verbosely files processed" - echo " --tar Create tar.gz package instead of .zip" + echo " --tar Create tar.gz package" + echo " --zip Create zip package" echo " --help Show this help message" exit 0 @@ -75,12 +77,14 @@ show_usage() parse_arguments() { for arg do case "$arg" in + --add-tar) ADDTAR=1 ;; --debug) DEBUG=1;; --tmp=*) TMP=`echo "$arg" | sed -e "s;--tmp=;;"` ;; --suffix=*) SUFFIX=`echo "$arg" | sed -e "s;--suffix=;;"` ;; --dirname=*) DIRNAME=`echo "$arg" | sed -e "s;--dirname=;;"` ;; --silent) SILENT=1 ;; --tar) OUTTAR=1 ;; + --zip) OUTZIP=1 ;; --help) show_usage ;; *) echo "Unknown argument '$arg'" @@ -359,6 +363,10 @@ which_1 () # Create the result zip/tar file # +if [ [ "$OUTTAR" = "0" ] && [ "$OUTZIP" = "0" ] ]; then + OUTZIP=1 +fi + set_tarzip_options() { for arg @@ -385,43 +393,60 @@ set_tarzip_options() done } -if [ "$OUTTAR" = "1" ]; then - set_tarzip_options 'tar' -else - set_tarzip_options 'zip' -fi - -tar=`which_1 $ZIPFILE1 $ZIPFILE2` -if test "$?" = "1" -o "$tar" = "" -then - print_debug "Search failed for '$ZIPFILE1', '$ZIPFILE2', using default 'tar'" - tar=tar - set_tarzip_options 'tar' -fi # # Create the archive # +create_archive() +{ -print_debug "Using $tar to create archive" + print_debug "Using $tar to create archive" -cd $TMP + cd $TMP -rm -f $SOURCE/$NEW_NAME$EXT -$tar $OPT $SOURCE/$NEW_NAME$EXT $NEW_DIR_NAME -cd $SOURCE + rm -f $SOURCE/$NEW_NAME$EXT + $tar $OPT $SOURCE/$NEW_NAME$EXT $NEW_DIR_NAME + cd $SOURCE -if [ "$NEED_COMPRESS" = "1" ] -then - print_debug "Compressing archive" - gzip -9 $NEW_NAME$EXT - EXT="$EXT.gz" + if [ "$NEED_COMPRESS" = "1" ] + then + print_debug "Compressing archive" + gzip -9 $NEW_NAME$EXT + EXT="$EXT.gz" + fi + + if [ "$SILENT" = "0" ] ; then + echo "$NEW_NAME$EXT created successfully !!" + fi +} + +if [ "$OUTTAR" = "1" ]; then + set_tarzip_options 'tar' + + tar=`which_1 $ZIPFILE1 $ZIPFILE2` + if test "$?" = "1" -o "$tar" = "" + then + print_debug "Search failed for '$ZIPFILE1', '$ZIPFILE2', using default 'tar'" + tar=tar + set_tarzip_options 'tar' + fi + + create_archive +fi + +if [ "$OUTZIP" = "1" ]; then + set_tarzip_options 'zip' + + tar=`which_1 $ZIPFILE1 $ZIPFILE2` + if test "$?" = "1" -o "$tar" = "" + then + echo "Search failed for '$ZIPFILE1', '$ZIPFILE2', cannot create zip!" + fi + + create_archive fi print_debug "Removing temporary directory" rm -r -f $BASE -if [ "$SILENT" = "0" ] ; then - echo "$NEW_NAME$EXT created successfully !!" -fi # End of script From ccd828900b1d7cbb4e68562b06e1d8d7455eea5e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Aug 2003 09:54:19 +0300 Subject: [PATCH 037/282] Cleanups to recent patches Fix packet error when using wrong GRANT command include/config-win.h: Changed back to test for HAVE_SETFILEPOINTER instead of operating system mysql-test/r/grant.result: Extra test to catch wrong packet bug mysql-test/t/grant.test: Extra test to catch wrong packet bug mysys/my_chsize.c: Cleanup sql/opt_range.cc: Fix to recent BETWEEN patch sql/sql_acl.cc: Fix packet error when using wrong GRANT command sql/sql_select.cc: Cleanups Added not critical out-of-memory check --- include/config-win.h | 1 + mysql-test/r/grant.result | 3 + mysql-test/t/grant.test | 5 ++ mysys/my_chsize.c | 143 +++++++++++++++++--------------------- sql/opt_range.cc | 3 +- sql/sql_acl.cc | 2 +- sql/sql_select.cc | 10 ++- 7 files changed, 84 insertions(+), 83 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index 69020636893..9f903b3bcd2 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -276,6 +276,7 @@ inline double ulonglong2double(ulonglong value) #define HAVE_ISAM /* We want to have support for ISAM in 4.0 */ #define HAVE_QUERY_CACHE #define SPRINTF_RETURNS_INT +#define HAVE_SETFILEPOINTER #ifdef NOT_USED #define HAVE_SNPRINTF /* Gave link error */ diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index fccd3715af7..4ce22e84dd5 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -108,3 +108,6 @@ flush privileges; drop table t1; GRANT FILE on mysqltest.* to mysqltest_1@localhost; Wrong usage of DB GRANT and GLOBAL PRIVILEGES +select 1; +1 +1 diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 5b20354336c..4433c9cbffc 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -72,5 +72,10 @@ delete from mysql.tables_priv where user='mysqltest_1'; delete from mysql.columns_priv where user='mysqltest_1'; flush privileges; drop table t1; + +# +# Test some error conditions +# --error 1221 GRANT FILE on mysqltest.* to mysqltest_1@localhost; +select 1; -- To test that the previous command didn't cause problems diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index e8c3c056029..11187cf4522 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -30,7 +30,7 @@ MyFlags Flags DESCRIPTION - my_chsize() truncates file if shorter, else fill with the filler character + my_chsize() truncates file if shorter else fill with the filler character RETURN VALUE 0 Ok @@ -38,89 +38,74 @@ */ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { + my_off_t oldsize; + char buff[IO_SIZE]; DBUG_ENTER("my_chsize"); DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength, MyFlags)); - /* if file is shorter, expand with null, else fill unused part with null */ + + oldsize = my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE)); + DBUG_PRINT("info",("old_size: %ld", (ulong) oldsize)); + + if (oldsize > newlength) +#if defined(HAVE_SETFILEPOINTER) + /* This is for the moment only true on windows */ { - my_off_t oldsize; - char buff[IO_SIZE]; - - oldsize = my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE)); - DBUG_PRINT("info",("old_size: %ld", (ulong) oldsize)); - -#ifdef __WIN__ - if (oldsize > newlength) + LARGE_INTEGER new_length; + HANDLE win_file= (HANDLE) _get_osfhandle(fd); + new_length.QuadPart = newlength; + if (SetFilePointerEx(win_file,new_length,NULL,FILE_BEGIN)) { - LARGE_INTEGER new_length; - HANDLE win_file; - win_file= (HANDLE)_get_osfhandle(fd); - new_length.QuadPart = newlength; - if (SetFilePointerEx(win_file,new_length,NULL,FILE_BEGIN)) - { - if (SetEndOfFile(win_file)) - DBUG_RETURN(0); - } - DBUG_PRINT("error",("errno: %d",errno)); - my_errno=errno; - if (MyFlags & MY_WME) - my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); - DBUG_RETURN(1); + if (SetEndOfFile(win_file)) + DBUG_RETURN(0); } -#elif defined(HAVE_CHSIZE) - if (oldsize > newlength || filler == 0) - { - if (chsize(fd,(off_t) newlength)) - { - DBUG_PRINT("error",("errno: %d",errno)); - my_errno=errno; - if (MyFlags & MY_WME) - my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),errno); - DBUG_RETURN(1); - } - else - { - if (filler == 0) - DBUG_RETURN(0); - } - } -#elif defined(HAVE_FTRUNCATE) - if (oldsize > newlength) - { - if (ftruncate(fd, (off_t) newlength)) - { - my_errno=errno; - DBUG_PRINT("error",("errno: %d",errno)); - if (MyFlags & MY_WME) - my_error(EE_CANT_CHSIZE, MYF(ME_BELL+ME_WAITTANG), errno); - DBUG_RETURN(1); - } - DBUG_RETURN(0); - } -#else - if (oldsize > newlength) - { /* Fill diff with null */ - VOID(my_seek(fd, newlength, MY_SEEK_SET, MYF(MY_WME+MY_FAE))); - swap(my_off_t, newlength, oldsize); - } -#endif - /* Full file with 0 until it's as big as requested */ - bfill(buff, IO_SIZE, filler); - while (newlength-oldsize > IO_SIZE) - { - if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP))) - goto err; - oldsize+= IO_SIZE; - } - if (my_write(fd,(byte*) buff,(uint) (newlength-oldsize),MYF(MY_NABP))) - goto err; - DBUG_RETURN(0); - err: - if (MyFlags & MY_WME) - my_error(EE_CANT_CHSIZE,MYF(ME_BELL+ME_WAITTANG),my_errno); - DBUG_PRINT("error",("errno: %d",my_errno)); - DBUG_RETURN(1); + my_errno= errno; + goto err; } +#elif defined(HAVE_FTRUNCATE) + { + if (ftruncate(fd, (off_t) newlength)) + { + my_errno= errno; + goto err; + } + DBUG_RETURN(0); + } +#elif defined(HAVE_CHSIZE) + { + if (chsize(fd, (off_t) newlength)) + { + my_errno=errno; + goto err; + } + DBUG_RETURN(0); + } +#else + { + /* + Fill space between requested length and true length with 'filler' + We should never come here on any modern machine + */ + VOID(my_seek(fd, newlength, MY_SEEK_SET, MYF(MY_WME+MY_FAE))); + swap(my_off_t, newlength, oldsize); + } +#endif + + /* Full file with 'filler' until it's as big as requested */ + bfill(buff, IO_SIZE, filler); + while (newlength-oldsize > IO_SIZE) + { + if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP))) + goto err; + oldsize+= IO_SIZE; + } + if (my_write(fd,(byte*) buff,(uint) (newlength-oldsize),MYF(MY_NABP))) + goto err; + DBUG_RETURN(0); + +err: + DBUG_PRINT("error", ("errno: %d", errno)); + if (MyFlags & MY_WME) + my_error(EE_CANT_CHSIZE, MYF(ME_BELL+ME_WAITTANG), my_errno); + DBUG_RETURN(1); } /* my_chsize */ - - diff --git a/sql/opt_range.cc b/sql/opt_range.cc index c7bad3b18f3..349a5d0271c 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -798,7 +798,8 @@ static SEL_TREE *get_mm_tree(PARAM *param,COND *cond) table_map ref_tables=cond->used_tables(); if (cond->type() != Item::FUNC_ITEM) { // Should be a field - if (ref_tables & param->current_table) + if ((ref_tables & param->current_table) || + (ref_tables & ~(param->prev_tables | param->read_tables))) DBUG_RETURN(0); DBUG_RETURN(new SEL_TREE(SEL_TREE::MAYBE)); } diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 6df778c997b..83cd2c7d2b4 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -2370,7 +2370,7 @@ int mysql_grant (THD *thd, const char *db, List &list, else { net_printf(&thd->net,ER_WRONG_USAGE,"DB GRANT","GLOBAL PRIVILEGES"); - result= -1; + result= 1; } } } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c4c2f890f5d..7922af04ea8 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1490,11 +1490,15 @@ add_key_field(KEY_FIELD **key_fields,uint and_level, } } DBUG_ASSERT(num_values == 1); - // DBUG_ASSERT(eq_func); /* QQ: Can I uncomment this ASSERT ? */ + /* + For the moment eq_func is always true. This slot is reserved for future + extensions where we want to remembers other things than just eq comparisons + */ + DBUG_ASSERT(eq_func); /* Store possible eq field */ (*key_fields)->field=field; (*key_fields)->eq_func=eq_func; - (*key_fields)->val=*value; + (*key_fields)->val= *value; (*key_fields)->level=(*key_fields)->const_level=and_level; (*key_fields)->exists_optimize=exists_optimize; (*key_fields)++; @@ -1582,6 +1586,8 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level, if (cond_func->arguments()[0]->type() == Item::FIELD_ITEM) { Item *tmp=new Item_null; + if (!tmp) // Should never be true + return; add_key_field(key_fields,*and_level, ((Item_field*) (cond_func->arguments()[0]))->field, cond_func->functype() == Item_func::ISNULL_FUNC, From 4363c28c24fe65061f5d01d92d119dbeed4c6e28 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 15 Aug 2003 14:55:05 +0200 Subject: [PATCH 038/282] - Added some files to support-files/MacOSX to enable building the Mac OS X startup item: MySQL (the startup script), StartupItem.Description.plist, StartupItem.Info.plist (PKGMaker control files), StartupItem.postinstall (post-installation script for the Startup Item package) - modified support-files/MacOSX/Makefile.am to include the newly added files in the source distribution BitKeeper/etc/ignore: Added scripts/make_win_src_distribution to the ignore list support-files/MacOSX/Makefile.am: - added the Mac OS X StartupItem files to the source distribution --- .bzrignore | 1 + support-files/MacOSX/Makefile.am | 6 ++- support-files/MacOSX/MySQL | 46 +++++++++++++++++++ .../MacOSX/StartupItem.Description.plist | 15 ++++++ support-files/MacOSX/StartupItem.Info.plist | 42 +++++++++++++++++ support-files/MacOSX/StartupItem.postinstall | 36 +++++++++++++++ 6 files changed, 145 insertions(+), 1 deletion(-) create mode 100755 support-files/MacOSX/MySQL create mode 100644 support-files/MacOSX/StartupItem.Description.plist create mode 100644 support-files/MacOSX/StartupItem.Info.plist create mode 100755 support-files/MacOSX/StartupItem.postinstall diff --git a/.bzrignore b/.bzrignore index a18a5008cb0..8514eb6ffb1 100644 --- a/.bzrignore +++ b/.bzrignore @@ -535,3 +535,4 @@ Docs/internals.html Docs/internals.pdf Docs/internals.txt Docs/internals_toc.html +scripts/make_win_src_distribution diff --git a/support-files/MacOSX/Makefile.am b/support-files/MacOSX/Makefile.am index b8047942190..ff16fa3235a 100644 --- a/support-files/MacOSX/Makefile.am +++ b/support-files/MacOSX/Makefile.am @@ -22,7 +22,11 @@ EXTRA_DIST = Info.plist.sh \ StartupParameters.plist.sh \ postinstall.sh \ preinstall.sh \ - ReadMe.txt + ReadMe.txt \ + MySQL \ + StartupItem.Description.plist \ + StartupItem.Info.plist \ + StartupItem.postinstall pkgdata_DATA = Info.plist \ Description.plist \ diff --git a/support-files/MacOSX/MySQL b/support-files/MacOSX/MySQL new file mode 100755 index 00000000000..dfba5f8f982 --- /dev/null +++ b/support-files/MacOSX/MySQL @@ -0,0 +1,46 @@ +#!/bin/sh +# +# /Library/StartupItems/MySQL/MySQL +# +# A script to automatically start up MySQL on system bootup +# for Mac OS X. This is actually just a wrapper script around +# the standard mysql.server init script, which is included in +# the binary distribution. +# +# (c) 2003 MySQL AB +# Written by Lenz Grimmer +# + +# Source the common setup functions for startup scripts +test -r /etc/rc.common || exit 1 +. /etc/rc.common + +# The path to the mysql.server init script. The official MySQL +# Mac OS X packages are being installed into /usr/local/mysql. +SCRIPT="/usr/local/mysql/support-files/mysql.server" + +StartService () +{ + if [ "${MYSQLCOM:=-NO-}" = "-YES-" ] ; then + ConsoleMessage "Starting MySQL database server" + $SCRIPT start > /dev/null 2>&1 + fi +} + +StopService () +{ + ConsoleMessage "Stopping MySQL database server" + $SCRIPT stop > /dev/null 2>&1 +} + +RestartService () +{ + ConsoleMessage "Restarting MySQL database server" + $SCRIPT restart > /dev/null 2>&1 +} + +if test -x $SCRIPT ; then + RunService "$1" +else + ConsoleMessage "Could not find MySQL startup script!" +fi diff --git a/support-files/MacOSX/StartupItem.Description.plist b/support-files/MacOSX/StartupItem.Description.plist new file mode 100644 index 00000000000..1f0023bde0d --- /dev/null +++ b/support-files/MacOSX/StartupItem.Description.plist @@ -0,0 +1,15 @@ + + + + + IFPkgDescriptionDeleteWarning + + IFPkgDescriptionDescription + This package enables MySQL to be started up automatically + on system bootup. + IFPkgDescriptionTitle + MySQL Startup Item + IFPkgDescriptionVersion + 1.0 + + diff --git a/support-files/MacOSX/StartupItem.Info.plist b/support-files/MacOSX/StartupItem.Info.plist new file mode 100644 index 00000000000..6bcae9397e5 --- /dev/null +++ b/support-files/MacOSX/StartupItem.Info.plist @@ -0,0 +1,42 @@ + + + + + CFBundleGetInfoString + MySQL Startup Item + CFBundleIdentifier + com.mysql.mysqlstartup + CFBundleName + MySQL Startup Item + CFBundleShortVersionString + 1.0 + IFMajorVersion + 1 + IFMinorVersion + 0 + IFPkgFlagAllowBackRev + + IFPkgFlagAuthorizationAction + RootAuthorization + IFPkgFlagDefaultLocation + /Library/StartupItems/ + IFPkgFlagInstallFat + + IFPkgFlagIsRequired + + IFPkgFlagOverwritePermissions + + IFPkgFlagRelocatable + + IFPkgFlagRestartAction + NoRestart + IFPkgFlagRootVolumeOnly + + IFPkgFlagUpdateInstalledLanguages + + IFPkgFlagUseUserMask + + IFPkgFormatVersion + 0.10000000149011612 + + diff --git a/support-files/MacOSX/StartupItem.postinstall b/support-files/MacOSX/StartupItem.postinstall new file mode 100755 index 00000000000..f6f6f46f211 --- /dev/null +++ b/support-files/MacOSX/StartupItem.postinstall @@ -0,0 +1,36 @@ +#!/bin/sh +# +# postinstall script for the MySQL Startup Item Installation package +# +# This script modifies /etc/hostconfig in the following ways: +# +# - On Mac OS X Server, it disables the startup of the default MySQL +# installation by changing the "MYSQL" start variable to "-NO-". +# - If not existent already, it adds a "MYSQLCOM" start variable, which +# defaults to "-YES-". An already existing MYSQLCOM variable will remain +# untouched. +# +# (c) 2003 MySQL AB +# Author: Lenz Grimmer +# + +CONFFILE="/etc/hostconfig" +TMPFILE=`basename $CONFFILE` || exit 1 +TMPFILE=`mktemp -t $TMPFILE.tmp` || exit 1 + +test -e $CONFFILE || exit 1 + +# Disable the startup of the default MySQL installation that ships with +# Mac OS X Server to avoid conflicts with our installation on bootup +sed -e s/^MYSQL=-YES-/MYSQL=-NO-/g < $CONFFILE > $TMPFILE + +# Add our MYSQLCOM startup variable (enabled by default) +grep -q "^MYSQLCOM" $CONFFILE > /dev/null 2>&1 +if [ $? -ne 0 ] ; then + echo "MYSQLCOM=-YES-" >> $TMPFILE +fi + +# Install the modified file into the default location +cp -f $CONFFILE $CONFFILE~ || exit 1 +mv -f $TMPFILE $CONFFILE || echo "Error while installing new $CONFFILE!" +chmod 644 $CONFFILE From 5ef233aa3978b00c013baccb3750931fd64efaa5 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 16 Aug 2003 17:03:48 +0300 Subject: [PATCH 039/282] Fixed a limitation bug in mysqlimport. sql_statement was designed to contain max 1280 characters, but sometimes in rare cases when --columns was used, more than 1280 characters was needed. This is case when a lot of columns was specified using this option. Raised the max value to 8448, which should be enough. --- client/mysqlimport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqlimport.c b/client/mysqlimport.c index a11b7383517..d7f6c4c0368 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -238,7 +238,7 @@ static int get_options(int *argc, char ***argv) static int write_to_table(char *filename, MYSQL *sock) { char tablename[FN_REFLEN], hard_path[FN_REFLEN], - sql_statement[FN_REFLEN*2+256], *end; + sql_statement[FN_REFLEN*16+256], *end; my_bool local_file; DBUG_ENTER("write_to_table"); DBUG_PRINT("enter",("filename: %s",filename)); From 0eaf4d8d7e879b32d5e1e0c7ecb409bc4d4cb060 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Aug 2003 14:10:15 +0300 Subject: [PATCH 040/282] Fix mutex handling in SHOW_VARIABLES (key_buffer_size was not properly protected) Changed some non fatal myisamchk error messages to warnings myisam/myisamchk.c: Change error -> warning sql/handler.cc: Add mutex around keybuff_size usage sql/mysql_priv.h: Indentation update sql/set_var.cc: Add mutex around longlong variable usage sql/sql_parse.cc: Fix mutex handling in SHOW_VARIABLES sql/sql_show.cc: Fix mutex handling in SHOW_VARIABLES --- myisam/myisamchk.c | 9 +++++---- sql/handler.cc | 17 ++++++++++++++--- sql/mysql_priv.h | 3 ++- sql/set_var.cc | 22 ++++++++++++++++++++-- sql/sql_parse.cc | 5 +++-- sql/sql_show.cc | 12 +++++------- 6 files changed, 49 insertions(+), 19 deletions(-) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index 4fadfd2fc5d..a0b4515f1dd 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -1400,21 +1400,22 @@ static int mi_sort_records(MI_CHECK *param, if (!(((ulonglong) 1 << sort_key) & share->state.key_map)) { - mi_check_print_error(param,"Can't sort table '%s' on key %d; No such key", + mi_check_print_warning(param, + "Can't sort table '%s' on key %d; No such key", name,sort_key+1); param->error_printed=0; DBUG_RETURN(0); /* Nothing to do */ } if (keyinfo->flag & HA_FULLTEXT) { - mi_check_print_error(param,"Can't sort table '%s' on FULLTEXT key %d", - name,sort_key+1); + mi_check_print_warning(param,"Can't sort table '%s' on FULLTEXT key %d", + name,sort_key+1); param->error_printed=0; DBUG_RETURN(0); /* Nothing to do */ } if (share->data_file_type == COMPRESSED_RECORD) { - mi_check_print_error(param,"Can't sort read-only table '%s'", name); + mi_check_print_warning(param,"Can't sort read-only table '%s'", name); param->error_printed=0; DBUG_RETURN(0); /* Nothing to do */ } diff --git a/sql/handler.cc b/sql/handler.cc index 505f64dff43..96611301bfa 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1020,14 +1020,25 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info, void ha_key_cache(void) { - if (keybuff_size) - (void) init_key_cache((ulong) keybuff_size); + /* + The following mutex is not really needed as long as keybuff_size is + treated as a long value, but we use the mutex here to guard for future + changes. + */ + pthread_mutex_lock(&LOCK_global_system_variables); + long tmp= keybuff_size; + pthread_mutex_unlock(&LOCK_global_system_variables); + if (tmp) + (void) init_key_cache(tmp); } void ha_resize_key_cache(void) { - (void) resize_key_cache((ulong) keybuff_size); + pthread_mutex_lock(&LOCK_global_system_variables); + long tmp= keybuff_size; + pthread_mutex_unlock(&LOCK_global_system_variables); + (void) resize_key_cache(tmp); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 0a4728ef325..e31038d7fee 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -507,7 +507,8 @@ void mysqld_list_processes(THD *thd,const char *user,bool verbose); int mysqld_show_status(THD *thd); int mysqld_show_variables(THD *thd,const char *wild); int mysqld_show(THD *thd, const char *wild, show_var_st *variables, - enum enum_var_type value_type); + enum enum_var_type value_type, + pthread_mutex_t *mutex); /* sql_handler.cc */ int mysql_ha_open(THD *thd, TABLE_LIST *tables); diff --git a/sql/set_var.cc b/sql/set_var.cc index b3238d1c0ec..6dc36e312cb 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -729,10 +729,12 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type) bool sys_var_long_ptr::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + pthread_mutex_lock(&LOCK_global_system_variables); if (option_limits) *value= (ulong) getopt_ull_limit_value(tmp, option_limits); else *value= (ulong) tmp; + pthread_mutex_unlock(&LOCK_global_system_variables); return 0; } @@ -746,17 +748,21 @@ void sys_var_long_ptr::set_default(THD *thd, enum_var_type type) bool sys_var_ulonglong_ptr::update(THD *thd, set_var *var) { ulonglong tmp= var->value->val_int(); + pthread_mutex_lock(&LOCK_global_system_variables); if (option_limits) *value= (ulonglong) getopt_ull_limit_value(tmp, option_limits); else *value= (ulonglong) tmp; + pthread_mutex_unlock(&LOCK_global_system_variables); return 0; } void sys_var_ulonglong_ptr::set_default(THD *thd, enum_var_type type) { + pthread_mutex_lock(&LOCK_global_system_variables); *value= (ulonglong) option_limits->def_value; + pthread_mutex_unlock(&LOCK_global_system_variables); } @@ -1000,9 +1006,21 @@ Item *sys_var::item(THD *thd, enum_var_type var_type) case SHOW_LONG: return new Item_uint((int32) *(ulong*) value_ptr(thd, var_type)); case SHOW_LONGLONG: - return new Item_int(*(longlong*) value_ptr(thd, var_type)); + { + longlong value; + pthread_mutex_lock(&LOCK_global_system_variables); + value= *(longlong*) value_ptr(thd, var_type); + pthread_mutex_unlock(&LOCK_global_system_variables); + return new Item_int(value); + } case SHOW_HA_ROWS: - return new Item_int((longlong) *(ha_rows*) value_ptr(thd, var_type)); + { + ha_rows value; + pthread_mutex_lock(&LOCK_global_system_variables); + value= *(ha_rows*) value_ptr(thd, var_type); + pthread_mutex_unlock(&LOCK_global_system_variables); + return new Item_int((longlong) value); + } case SHOW_MY_BOOL: return new Item_int((int32) *(my_bool*) value_ptr(thd, var_type),1); case SHOW_CHAR: diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 70c0f772d7d..780c97654f5 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2146,11 +2146,12 @@ mysql_execute_command(void) break; case SQLCOM_SHOW_STATUS: res= mysqld_show(thd,(lex->wild ? lex->wild->ptr() : NullS),status_vars, - OPT_GLOBAL); + OPT_GLOBAL, &LOCK_status); break; case SQLCOM_SHOW_VARIABLES: res= mysqld_show(thd, (lex->wild ? lex->wild->ptr() : NullS), - init_vars, lex->option_type); + init_vars, lex->option_type, + &LOCK_global_system_variables); break; case SQLCOM_SHOW_LOGS: { diff --git a/sql/sql_show.cc b/sql/sql_show.cc index d591a44accf..489635bd85f 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1158,7 +1158,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) int mysqld_show(THD *thd, const char *wild, show_var_st *variables, - enum enum_var_type value_type) + enum enum_var_type value_type, + pthread_mutex_t *mutex) { char buff[8192]; String packet2(buff,sizeof(buff)); @@ -1171,8 +1172,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, if (send_fields(thd,field_list,1)) DBUG_RETURN(1); /* purecov: inspected */ - /* pthread_mutex_lock(&THR_LOCK_keycache); */ - pthread_mutex_lock(&LOCK_status); + pthread_mutex_lock(mutex); for (; variables->name; variables++) { if (!(wild && wild[0] && wild_case_compare(variables->name,wild))) @@ -1413,14 +1413,12 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, goto err; /* purecov: inspected */ } } - pthread_mutex_unlock(&LOCK_status); - /* pthread_mutex_unlock(&THR_LOCK_keycache); */ + pthread_mutex_unlock(&mutex); send_eof(&thd->net); DBUG_RETURN(0); err: - pthread_mutex_unlock(&LOCK_status); - /* pthread_mutex_unlock(&THR_LOCK_keycache); */ + pthread_mutex_unlock(&mutex); DBUG_RETURN(1); } From 79e3476071b517900f42dae9f10c73d76f1f4c95 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 17 Aug 2003 14:37:26 +0300 Subject: [PATCH 041/282] fixed typo in last push --- sql/sql_show.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 489635bd85f..0321eb3cbba 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1413,12 +1413,12 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, goto err; /* purecov: inspected */ } } - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(mutex); send_eof(&thd->net); DBUG_RETURN(0); err: - pthread_mutex_unlock(&mutex); + pthread_mutex_unlock(mutex); DBUG_RETURN(1); } From 2f27739e06bf1033d0ce59c260aa225f92d011fc Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 18 Aug 2003 20:01:38 +0200 Subject: [PATCH 042/282] Fix for 64-bit CPUs (u_long is 64 bit there, but in_addr_t is always uint32). That's to make resolveip work on our FreeBSD-5.0/Sparc64 build host. extra/resolveip.c: Fix for 64-bit CPUs (u_long is 64 bit there, but in_addr_t is always uint32). --- extra/resolveip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extra/resolveip.c b/extra/resolveip.c index ba2db0a4d65..764844bf622 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -110,7 +110,7 @@ static int get_options(int *argc,char ***argv) int main(int argc, char **argv) { struct hostent *hpaddr; - u_long taddr; + in_addr_t taddr; char *ip,**q; int error=0; From 9194f5ef335947077a53d054e2dd41b237fb5d23 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 13:49:53 +0200 Subject: [PATCH 043/282] - Optimized and cleaned up the Do-rpm and Bootstrap Perl scripts - Enhanced Do-rpm to support building RPMs with different compilers and options Build-tools/Bootstrap: - small optimization (use builtin Perl cwd() function instead of running "pwd" twice) Build-tools/Do-rpm: - added options to handle different compilers and compile flags (e.g. when compiling on IA64 using the Intel ecc compiler) - code cleanups (use more builtin Perl functions instead of forking subrocesses) - don't try to probe various distribution-specific RPM options - query rpm directly instead - Pass the MySQL version as an argument, not an option (as it's not optional anyway) --- Build-tools/Bootstrap | 11 ++-- Build-tools/Do-rpm | 138 ++++++++++++++++++++++++++++++------------ 2 files changed, 104 insertions(+), 45 deletions(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 1facf7b5f0d..4a2e6f284f2 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -10,6 +10,7 @@ # written by Lenz Grimmer # +use Cwd; use Getopt::Long; Getopt::Long::Configure ("bundling"); @@ -26,10 +27,9 @@ else # Some predefined settings $build_command= "BUILD/compile-pentium-max"; -chomp ($LOGFILE= `pwd`); -$LOGFILE.= "/Bootstrap.log"; -chomp ($opt_directory= `pwd`); -$opt_docdir= $opt_directory . "/mysqldoc"; +$PWD= cwd(); +$LOGFILE= $PWD . "/Bootstrap.log"; +$opt_docdir= $PWD . "/mysqldoc"; $opt_build_command= undef; $opt_changelog= undef; $opt_delete= undef; @@ -82,8 +82,7 @@ if (defined $opt_log) } else { - chomp ($LOGFILE= `pwd`); - $LOGFILE.= "/" . $opt_log; + $LOGFILE= $PWD . "/" . $opt_log; } } } diff --git a/Build-tools/Do-rpm b/Build-tools/Do-rpm index 77f87cd0358..0f423feb921 100755 --- a/Build-tools/Do-rpm +++ b/Build-tools/Do-rpm @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# Do-rpm - compile RPM packages out of a source tarball and copy the +# Do-rpm - compile RPM packages out of a source tarball and move the # resulting RPM packages into the current directory. # # The script currently assumes the following environment (which should exist @@ -17,27 +17,43 @@ # written by Lenz Grimmer # +use Cwd; +use File::Basename; +use File::Copy; use Getopt::Long; Getopt::Long::Configure ("bundling"); +use Sys::Hostname; +$opt_cc= undef; +$opt_cflags= undef; +$opt_clean= undef; +$opt_cxx= undef; +$opt_cxxflags= undef; $opt_dry_run= undef; $opt_help= undef; $opt_log= undef; $opt_mail= ""; $opt_verbose= undef; -$opt_version= undef; + +$MAJOR= $MINOR= $RELEASE= 0; GetOptions( - "dry-run", + "cc=s", + "cflags=s", + "clean|c", + "cxx=s", + "cxxflags=s", + "dry-run|t", "help|h", "log|l:s", "mail|m=s", "verbose|v", - "version=s", ) || &print_help; +defined($VERSION=$ARGV[0]) || print_help("Please provide the MySQL version!"); + # Include helper functions -chomp($PWD= `pwd`); +$PWD= cwd(); $LOGGER= "$PWD/logger.pm"; if (-f "$LOGGER") { @@ -66,10 +82,16 @@ if (defined $opt_log) } } -&print_help("") if ($opt_help || !$opt_version); +($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION); +$HOST= hostname(); +$HOST=~ /^([^.-]*)/; +$HOST= $1; +$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log"; + +&print_help("") if ($opt_help); # -# Newer RPM version ship with a separate tool to build RPMs +# Newer RPM versions ship with a separate tool "rpmbuild" to build RPMs # if (-x "/usr/bin/rpmbuild") { @@ -80,24 +102,24 @@ else $RPM= "/bin/rpm"; } -foreach $DIR ("/usr/src/packages", "/usr/src/redhat") +if ($RPM) { - if (-d $DIR) - { - $TOPDIR= $DIR; - last; - } + &logger("Found rpm binary: $RPM"); +} +else +{ + &abort("Unable to find RPM binary!"); } -$SPECDIR= $TOPDIR . "/SPECS"; -$SOURCEDIR= $TOPDIR . "/SOURCES"; +# +# determine some RPM settings for this host +# +chomp($RPMARCH= `$RPM --eval "%{_arch}" 2> /dev/null`); +chomp($RPMDIR= `$RPM --eval "%{_rpmdir}" 2> /dev/null`); +chomp($SOURCEDIR= `$RPM --eval "%{_sourcedir}" 2> /dev/null`); +chomp($SPECDIR= `$RPM --eval "%{_specdir}" 2> /dev/null`); +chomp($SRCRPMDIR= `$RPM --eval "%{_srcrpmdir}" 2> /dev/null`); -$VERSION= $opt_version; -($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION); -chomp($HOST= `hostname`); -$HOST=~ /^([^.-]*)/; -$HOST= $1; -$LOGFILE= "$PWD/Logs/Do-rpm-$HOST-$MAJOR.$MINOR.log"; $SOURCEFILE= "mysql-$VERSION.tar.gz"; $SPECFILE= "$PWD/$HOST/mysql-$VERSION/support-files/mysql-$VERSION.spec"; @@ -112,23 +134,56 @@ foreach $file ($SOURCEFILE, $SPECFILE) # Install source and spec file # &logger("Copying SOURCE and SPEC file to build directories."); -$command= "cp"; -$command.= " -v" if ($opt_verbose); -$command.= " $SOURCEFILE $SOURCEDIR"; -&run_command($command, "Unable to copy $SOURCEFILE to $SOURCEDIR!"); -$command= "cp"; -$command.= " -v" if ($opt_verbose); -$command.= " $SPECFILE $SPECDIR"; -&run_command($command, "Unable to copy $SPECFILE to $SPECDIR!"); +copy($SOURCEFILE, $SOURCEDIR) +or &abort("Unable to copy $SOURCEFILE to $SOURCEDIR!"); +copy($SPECFILE, $SPECDIR) +or &abort("Unable to copy $SPECFILE to $SPECDIR!"); + +# +# Set environment variables - these are being used in the +# official MySQL RPM spec file +# +&logger("Setting special build environment variables") +if ($opt_cc) or ($opt_cflags) or ($opt_cxxflags) or ($opt_cxx); +$ENV{MYSQL_BUILD_CC}=$opt_cc if ($opt_cc); +$ENV{MYSQL_BUILD_CFLAGS}=$opt_cflags if ($opt_cflags); +$ENV{MYSQL_BUILD_CXXFLAGS}=$opt_cxxflags if ($opt_cxxflags); +$ENV{MYSQL_BUILD_CXX}=$opt_cxx if ($opt_cxx); # # Build the RPMs # $command= "$RPM"; -$command.=" -v" if ($opt_verbose); -$command.=" -ba --clean $SPECDIR/$SPECFILE"; -&logger("Builing RPM."); -&run_command($command, "Unable to build RPM!"); +$command.= " -v" if ($opt_verbose); +$command.= " -ba"; +$command.= " --clean" if $opt_clean; +$command.= " $SPECDIR/"; +$command.= basename($SPECFILE); +&logger("Building RPM."); +&run_command($command, "Error while building the RPMs!"); + +# +# Move the resulting RPMs into the pwd +# +$command= "mv"; +$command.= " -v " if ($opt_verbose); +$command.= "$SRCRPMDIR/MySQL*$VERSION*.src.rpm $PWD"; +&run_command($command, "Error moving source RPM!"); + +$command= "mv"; +$command.= " -v " if ($opt_verbose); +$command.= "$RPMDIR/$RPMARCH/MySQL*$VERSION*.$RPMARCH.rpm $PWD"; +&run_command($command, "Error moving binary RPMs!"); + +# +# Clean up +# +if ($opt_clean) +{ + &logger("Removing spec file and source package"); + unlink("$SPECDIR/" . basename($SPECFILE)); + unlink("$SOURCEDIR/$SOURCEFILE"); +} &logger("SUCCESS: RPM files successfully created.") if (!$opt_dry_run); exit 0; @@ -139,18 +194,24 @@ sub print_help if ($message ne "") { print "\n"; - print "ERROR: $message\n"; + print "ERROR: $message\n\n}"; } print < --version= +Usage: Do-rpm -Creates a binary RPM package out of a MySQL source distribution and copy the -resulting RPMs into the current directory. +Creates a binary RPM package out of a MySQL source distribution and moves the +resulting RPMs into the current directory. is the MySQL version +number (e.g. 4.0.11-gamma) Options: - --dry-run Dry run without executing + --cc= Use to compile C code + --ccflags= Use special C compiler flags + --cxx= Use to compile C++ code + --cxxflags= Use special C++ compiler flags +-c, --clean Clean up after the build +-t, --dry-run Dry run without executing -h, --help Print this help -l, --log[=] Write a log file [to ] (default is "$LOGFILE") @@ -159,7 +220,6 @@ Options: is enabled) Note that the \@-Sign needs to be quoted! Example: --mail=user\\\@domain.com - --version= The MySQL version number (e.g. 4.0.11-gamma) -v, --verbose Verbose execution EOF From a8aaa3ef46cdf3ecb916b6a15c354663c837fc55 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 13:57:58 +0200 Subject: [PATCH 044/282] - Do-pkg can now create a separate package including a MySQL Startup Item for Mac OS X and add it to the installation Disk Image. Build-tools/Do-pkg: - added code to build the StartupItem PKG along with the MySQL PKG and add it to the resulting Disk Image (can be skipped with --skip-si) - lots of cleanups (use more builtin Perl functions instead of subprocesses, enable a full dry run without errors) support-files/MacOSX/StartupItem.Info.plist: - removed IFPkgFlagOverwritePermissions and IFPkgFlagUseUserMask --- Build-tools/Do-pkg | 127 +++++++++++++++----- support-files/MacOSX/StartupItem.Info.plist | 6 +- 2 files changed, 96 insertions(+), 37 deletions(-) diff --git a/Build-tools/Do-pkg b/Build-tools/Do-pkg index e95d86c0f6e..4d0f120c6e3 100755 --- a/Build-tools/Do-pkg +++ b/Build-tools/Do-pkg @@ -1,7 +1,9 @@ #!/usr/bin/perl -w # # Do-pkg - convert a binary distribution into a Mac OS X PKG and put it -# inside a Disk Image (.dmg) +# inside a Disk Image (.dmg). Additionally, add a separate package, +# including the required Startup Item to automatically start MySQL on +# bootup. # # The script currently assumes the following environment (which should exist # like that, if the Do-compile script was used to build the binary @@ -17,14 +19,19 @@ # written by Lenz Grimmer # +use Cwd; +use File::Basename; +use File::Copy; use Getopt::Long; Getopt::Long::Configure ("bundling"); +use Sys::Hostname; $opt_dry_run= undef; $opt_help= undef; $opt_log= undef; $opt_mail= ""; $opt_skip_dmg= undef; +$opt_skip_si= undef; $opt_suffix= undef; $opt_verbose= undef; $opt_version= undef; @@ -35,13 +42,14 @@ GetOptions( "log|l:s", "mail|m=s", "skip-dmg|skip-disk-image|s", + "skip-si|skip-startup-item", "suffix=s", "verbose|v", "version=s", ) || &print_help; # Include helper functions -chomp($PWD= `pwd`); +$PWD= cwd(); $LOGGER= "$PWD/logger.pm"; if (-f "$LOGGER") { @@ -54,7 +62,7 @@ else $PM= "/Developer/Applications/PackageMaker.app/Contents/MacOS/PackageMaker"; $TMP= $ENV{TMPDIR}; -$TMP eq "" ? $TMP= $TMP . "/PKGBUILD": $TMP= "/tmp/PKGBUILD"; +$TMP eq "" ? $TMP= $TMP . "/PKGBUILD.$$": $TMP= "/tmp/PKGBUILD.$$"; $PKGROOT= "$TMP/PMROOT"; $PKGDEST= "$TMP/PKG"; $RESOURCE_DIR= "$TMP/Resources"; @@ -62,8 +70,8 @@ $SUFFIX= $opt_suffix; $VERSION= $opt_version; ($MAJOR, $MINOR, $RELEASE)= split(/\./, $VERSION); $NAME= "mysql$SUFFIX-$VERSION"; -chomp($HOST= `hostname`); -chomp($ID= `whoami`); +$HOST= hostname(); +$ID= getpwuid($>); $HOST=~ /^([^.-]*)/; $HOST= $1; $LOGFILE= "$PWD/Logs/$HOST-$MAJOR.$MINOR$SUFFIX.log"; @@ -73,6 +81,12 @@ $SUPFILEDIR= <$SRCBASEDIR/support-files/MacOSX>; $TAR= <$BUILDDIR/$NAME-apple-darwin*-powerpc.tar.gz>; $INFO= <$SUPFILEDIR/Info.plist>; $DESC= <$SUPFILEDIR/Description.plist>; +$SI_INFO= <$SUPFILEDIR/StartupItem.Info.plist>; +$SI_DESC= <$SUPFILEDIR/StartupItem.Description.plist>; +$SI_PARAMS= <$SUPFILEDIR/StartupParameters.plist>; +$SI_POST= <$SUPFILEDIR/StartupItem.postinstall>; +$SI_NAME= "MySQLStartupItem"; +$SI_SCRIPT= <$SUPFILEDIR/MySQL>; @RESOURCES= qw/ ReadMe.txt postinstall preinstall /; @LICENSES= ("$SRCBASEDIR/COPYING","$SRCBASEDIR/MySQLEULA.txt"); @@ -99,7 +113,9 @@ if (defined $opt_log) # Creating the UFS disk image requires root privileges die("You must be root to run this script!") if ($ID ne "root" && !$opt_dry_run); -foreach $file ($TAR, $INFO, $DESC) +@files= ($TAR, $INFO, $DESC); +@files= (@files, $SI_INFO, $SI_DESC, $SI_POST, $SI_SCRIPT) unless $opt_skip_si; +foreach $file (@files) { &abort("Unable to find $file!") unless (-f "$file"); } @@ -112,14 +128,22 @@ foreach $dir ($TMP, $PKGROOT, $PKGDEST, $RESOURCE_DIR) { if (!-d $dir) { - &run_command("mkdir $dir", "Could not make directory $dir!"); + &logger("Creating directory $dir!"); + unless($opt_dry_run) + { + mkdir($dir) or &abort("Could not make directory $dir!"); + } } } foreach $resfile (@RESOURCES) { - $command= "cp $SUPFILEDIR/$resfile $RESOURCE_DIR"; - &run_command($command, "Error while copying $SUPFILEDIR/$resfile to $RESOURCE_DIR"); + &logger("Copying $SUPFILEDIR/$resfile to $RESOURCE_DIR"); + unless($opt_dry_run) + { + copy("$SUPFILEDIR/$resfile", "$RESOURCE_DIR") or + &abort("Error while copying $SUPFILEDIR/$resfile to $RESOURCE_DIR"); + } } # Search for license file @@ -127,12 +151,17 @@ foreach $license (@LICENSES) { if (-f "$license") { - $command= "cp $license $RESOURCE_DIR/License.txt"; - &run_command($command, "Error while copying $license to $RESOURCE_DIR"); + &logger("Copy $license to $RESOURCE_DIR/License.txt"); + unless($opt_dry_run) + { + copy("$license", "$RESOURCE_DIR/License.txt") or + &abort("Error while copying $license to $RESOURCE_DIR"); + } } } -&abort("Could not find a license file!") unless (-f "$RESOURCE_DIR/License.txt"); +&abort("Could not find a license file!") +unless (-f "$RESOURCE_DIR/License.txt"); # Extract the binary tarball and create the "mysql" symlink &logger("Extracting $TAR to $PKGROOT"); @@ -145,10 +174,38 @@ foreach $license (@LICENSES) # returning a non-zero value, even though the package was created correctly &logger("Running PackageMaker"); $command= "$PM -build -p $PKGDEST/$NAME.pkg -f $PKGROOT -r $RESOURCE_DIR -i $INFO -d $DESC || true"; -&run_command($command, "Error while building package!"); +&run_command($command, "Error while building package $NAME.pkg!"); -&logger("Removing $PKGROOT"); -&run_command("rm -rf $PKGROOT", "Unable to remove $PKGROOT!"); +# +# Build the Startup Item PKG +# +unless ($opt_skip_si) +{ + &logger("Cleaning up $PKGROOT"); + &run_command("rm -rf $PKGROOT/*", "Unable to clean up $PKGROOT!"); + &logger("Cleaning up $RESOURCE_DIR"); + &run_command("rm -rf $RESOURCE_DIR/*", "Unable to clean up $RESOURCE_DIR!"); + + &logger("Installing MySQL StartupItem files into $PKGROOT/MySQL"); + unless($opt_dry_run) + { + mkdir("$PKGROOT/MySQL") or &abort("Error creating $PKGROOT/MySQL"); + copy("$SI_SCRIPT", "$PKGROOT/MySQL/") + or &abort("Error copying $SI_SCRIPT!"); + chmod(0755, "$PKGROOT/MySQL/" . basename("$SI_SCRIPT")); + copy("$SI_PARAMS", "$PKGROOT/MySQL/") + or &abort("Error copying $SI_PARAMS!"); + chmod(0644, "$PKGROOT/MySQL/" . basename("$SI_PARAMS")); + &run_command("chown -R root.wheel $PKGROOT/*", "Cannot chown $PKGROOT!"); + copy("$SI_POST", "$RESOURCE_DIR/postinstall") + or &abort("Error copying $SI_POST!"); + chmod(0644, "$RESOURCE_DIR/postinstall"); + } + + &logger("Building $SI_NAME.pkg using PackageMaker"); + $command= "$PM -build -p $PKGDEST/$SI_NAME.pkg -f $PKGROOT -r $RESOURCE_DIR -i $SI_INFO -d $SI_DESC || true"; + &run_command($command, "Error while building package $SI_NAME.pkg!"); +} if ($opt_skip_dmg) { @@ -159,7 +216,7 @@ if ($opt_skip_dmg) # Determine the size of the Disk image to be created and add a 5% safety # margin for filesystem overhead &logger("Determining required disk image size for $PKGDEST"); -if (! $opt_dry_run) +unless($opt_dry_run) { chomp($_= `du -sk $PKGDEST`); @size= split(); @@ -167,7 +224,10 @@ if (! $opt_dry_run) &logger("Disk image size: $size KB"); } -&abort("Zero bytes? Something is wrong here!") if ($size == 0); +unless($opt_dry_run) +{ + &abort("Zero bytes? Something is wrong here!") if ($size == 0); +} # Now create and mount the disk image $TMPNAME= $NAME . ".tmp"; @@ -181,7 +241,7 @@ $command= "hdiutil create $TMPNAME -size ${size}k -ov -fs UFS -volname $NAME"; chomp($mountpoint=`mount | grep "\/Volumes\/$NAME" | cut -f3 -d" "`) if (!$opt_dry_run); &logger("Copying $PKGDEST/$NAME.pkg to Disk image /Volumes/$NAME"); &run_command("ditto $PKGDEST /Volumes/$NAME", "Could not copy $PKGDEST to /Volumes/$NAME!"); -&run_command("ditto $RESOURCE_DIR/ReadMe.txt /Volumes/$NAME", "Could not copy $RESOURCE_DIR/ReadMe.txt to /Volumes/$NAME!"); +&run_command("ditto $SUPFILEDIR/ReadMe.txt /Volumes/$NAME", "Could not copy $SPFILEDIR/ReadMe.txt to /Volumes/$NAME!"); chomp($mountpoint=`mount | grep "\/Volumes\/$NAME" | cut -f1 -d" "`) if (!$opt_dry_run); &abort("/Volumes/$NAME not attached!") if (!$mountpoint && !$opt_dry_run); &logger("Unmounting $mountpoint"); @@ -221,20 +281,23 @@ NOTE: You need to run this script with root privileges (required Options: - --dry-run Dry run without executing --h, --help Print this help --l, --log[=] Write a log file [to ] - (default is "$LOGFILE") --m, --mail=
Mail a failure report to the given address - (and include a log file snippet, if logging - is enabled) - Note that the \@-Sign needs to be quoted! - Example: --mail=user\\\@domain.com --s, --skip-disk-image Just build the PKG, don't put it into a - disk image afterwards - --suffix= The package suffix (e.g. "-standard" or "-pro) - --version= The MySQL version number (e.g. 4.0.11-gamma) --v, --verbose Verbose execution + --dry-run Dry run without executing +-h, --help Print this help +-l, --log[=] Write a log file [to ] + (default is "$LOGFILE") +-m, --mail=
Mail a failure report to the given + address (and include a log file snippet, + if logging is enabled) + Note that the \@-Sign needs to be quoted! + Example: --mail=user\\\@domain.com +-s, --skip-disk-image, --skip-dmg Just build the PKGs, don't put it into a + disk image afterwards + --skip-startup-item, --skip-si Skip the creation of the StartupItem PKG + --suffix= The package suffix + (e.g. "-standard" or "-pro) + --version= The MySQL version number + (e.g. 4.0.11-gamma) +-v, --verbose Verbose execution EOF exit 1; diff --git a/support-files/MacOSX/StartupItem.Info.plist b/support-files/MacOSX/StartupItem.Info.plist index 6bcae9397e5..f403fbe7e84 100644 --- a/support-files/MacOSX/StartupItem.Info.plist +++ b/support-files/MacOSX/StartupItem.Info.plist @@ -19,13 +19,11 @@ IFPkgFlagAuthorizationAction RootAuthorization IFPkgFlagDefaultLocation - /Library/StartupItems/ + /Library/StartupItems IFPkgFlagInstallFat IFPkgFlagIsRequired - IFPkgFlagOverwritePermissions - IFPkgFlagRelocatable IFPkgFlagRestartAction @@ -34,8 +32,6 @@ IFPkgFlagUpdateInstalledLanguages - IFPkgFlagUseUserMask - IFPkgFormatVersion 0.10000000149011612 From de9a0cbe2f37037f2d663abc3a01e85c03e734d0 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 16:03:18 +0300 Subject: [PATCH 045/282] Fix test case --- mysql-test/t/lock_tables_lost_commit-master.opt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/lock_tables_lost_commit-master.opt b/mysql-test/t/lock_tables_lost_commit-master.opt index d357a51cb27..51ccb915ef0 100644 --- a/mysql-test/t/lock_tables_lost_commit-master.opt +++ b/mysql-test/t/lock_tables_lost_commit-master.opt @@ -1 +1 @@ ---binlog-ignore-db=test innodb \ No newline at end of file +--binlog-ignore-db=test From c7578701e3e3a67fe137ef5788f6d8b98a2d6655 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 15:12:44 +0200 Subject: [PATCH 046/282] Fixes for BUG#1091,1092,1093. Synopsis of these bugs: mysqlbinlog segfaults if --position is just before Exec_load event mysqlbinlog prints uncommented warnings if --database and compiled with debug mysqlbinlog --database does not filter LOAD DATA INFILE client/mysqlbinlog.cc: * Don't stop in Append_block when there is no Create_file. Just print a warning. * Test LOAD DATA (Create_file) against --database. * Don't print "no skip" when you don't skip an event when using --database (it causes syntax errors in 'mysql'). * Print a warning in Exec_load if there is no Create_file. --- client/mysqlbinlog.cc | 90 ++++++++++++++++++++++++++----------------- 1 file changed, 54 insertions(+), 36 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ac1c9db30e6..954e9290a76 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -183,7 +183,16 @@ public: void process(Append_block_log_event *ae) { if (ae->file_id >= file_names.elements) - die("Skiped CreateFile event for file_id: %u",ae->file_id); + { + /* + There is no Create_file event (a bad binlog or a big + --position). Assuming it's a big --position, we just do nothing and + print a warning. + */ + fprintf(stderr,"Warning: ignoring Append_block as there is no \ +Create_file event for file_id: %u\n",ae->file_id); + return; + } Create_file_log_event* ce= *((Create_file_log_event**)file_names.buffer + ae->file_id); append_to_file(ce->fname,O_APPEND|O_BINARY|O_WRONLY,ae->block,ae->block_len); @@ -568,44 +577,42 @@ Could not read entry at offset %s : Error in log format or read error", } if (rec_count >= offset) { - // see if we should skip this event (only care about queries for now) - if (one_database) - { - if (ev->get_type_code() == QUERY_EVENT) - { - //const char * log_dbname = ev->get_db(); - const char * log_dbname = ((Query_log_event*)ev)->db; - //printf("entry: %llu, database: %s\n", rec_count, log_dbname); - - if ((log_dbname != NULL) && (strcmp(log_dbname, database))) - { - //printf("skipping, %s is not %s\n", log_dbname, database); - rec_count++; - delete ev; - continue; // next - } -#ifndef DBUG_OFF - else - { - printf("no skip\n"); - } -#endif - } -#ifndef DBUG_OFF - else - { - const char * query_type = ev->get_type_str(); - printf("not query -- %s\n", query_type); - } -#endif - } if (!short_form) fprintf(result_file, "# at %s\n",llstr(old_off,llbuff)); switch (ev->get_type_code()) { + case QUERY_EVENT: + if (one_database) + { + const char * log_dbname = ((Query_log_event*)ev)->db; + if ((log_dbname != NULL) && (strcmp(log_dbname, database))) + { + rec_count++; + delete ev; + continue; // next + } + } + ev->print(result_file, short_form, last_db); + break; case CREATE_FILE_EVENT: { Create_file_log_event* ce= (Create_file_log_event*)ev; + if (one_database) + { + /* + We test if this event has to be ignored. If yes, we don't save this + event; this will have the good side-effect of ignoring all related + Append_block and Exec_load. + Note that Load event from 3.23 is not tested. + */ + const char * log_dbname = ce->db; + if ((log_dbname != NULL) && (strcmp(log_dbname, database))) + { + rec_count++; + delete ev; + continue; // next + } + } ce->print(result_file, short_form, last_db,true); load_processor.process(ce); ev= 0; @@ -620,9 +627,20 @@ Could not read entry at offset %s : Error in log format or read error", ev->print(result_file, short_form, last_db); Execute_load_log_event *exv= (Execute_load_log_event*)ev; Create_file_log_event *ce= load_processor.grab_event(exv->file_id); - ce->print(result_file, short_form, last_db,true); - my_free((char*)ce->fname,MYF(MY_WME)); - delete ce; + /* + if ce is 0, it probably means that we have not seen the Create_file + event (a bad binlog, or most probably --position is after the + Create_file event). Print a warning comment. + */ + if (ce) + { + ce->print(result_file, short_form, last_db,true); + my_free((char*)ce->fname,MYF(MY_WME)); + delete ce; + } + else + fprintf(stderr,"Warning: ignoring Exec_load as there is no \ +Create_file event for file_id: %u\n",exv->file_id); break; } default: @@ -634,7 +652,7 @@ Could not read entry at offset %s : Error in log format or read error", delete ev; } if (fd >= 0) - my_close(fd, MYF(MY_WME)); + my_close(fd, MYF(MY_WME)); end_io_cache(file); } From fe0e54643492c6b689664ed09206db58dca29967 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 15:46:47 +0200 Subject: [PATCH 047/282] Fix for BUG#1096 which is: "mysqlbinlog does not comment the original LOAD DATA INFILE if it has a "use xx"" client/mysqlbinlog.cc: a comment sql/log_event.cc: in mysqlbinlog we want to have a leading '#' before LOAD DATA INFILE when we print a Create_file event. This was not done properly when the query had *2* lines: only the "use db" got commented. To fix this I had to add an argument to Load_log_event::print, it could not be handled in Create_file_log_event::print alone. sql/log_event.h: prototype --- client/mysqlbinlog.cc | 8 +++++++- sql/log_event.cc | 22 ++++++++++++++++------ sql/log_event.h | 1 + 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 954e9290a76..a454d6a859f 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -613,7 +613,13 @@ Could not read entry at offset %s : Error in log format or read error", continue; // next } } - ce->print(result_file, short_form, last_db,true); + /* + We print the event, but with a leading '#': this is just to inform the + user of the original command; the command we want to execute will be a + derivation of this original command (we will change the filename and + use LOCAL), prepared in the 'case EXEC_LOAD_EVENT' below. + */ + ce->print(result_file, short_form, last_db, true); load_processor.process(ce); ev= 0; break; diff --git a/sql/log_event.cc b/sql/log_event.cc index 3451ffab65f..591ebf2b5d8 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1279,6 +1279,11 @@ int Load_log_event::copy_log_event(const char *buf, ulong event_len, #ifdef MYSQL_CLIENT void Load_log_event::print(FILE* file, bool short_form, char* last_db) +{ + print(file, short_form, last_db, 0); +} + +void Load_log_event::print(FILE* file, bool short_form, char* last_db, bool commented) { if (!short_form) { @@ -1295,9 +1300,12 @@ void Load_log_event::print(FILE* file, bool short_form, char* last_db) } if (db && db[0] && !same_db) - fprintf(file, "use %s;\n", db); + fprintf(file, "%suse %s;\n", + commented ? "# " : "", + db); - fprintf(file, "LOAD DATA "); + fprintf(file, "%sLOAD DATA ", + commented ? "# " : ""); if (check_fname_outside_temp_buf()) fprintf(file, "LOCAL "); fprintf(file, "INFILE '%-*s' ", fname_len, fname); @@ -1573,10 +1581,12 @@ void Create_file_log_event::print(FILE* file, bool short_form, if (enable_local) { - if (!check_fname_outside_temp_buf()) - fprintf(file, "#"); - Load_log_event::print(file, 1, last_db); - fprintf(file, "#"); + Load_log_event::print(file, 1, last_db, !check_fname_outside_temp_buf()); + /* + That one is for "file_id: etc" below: in mysqlbinlog we want the #, in + SHOW BINLOG EVENTS we don't. + */ + fprintf(file, "#"); } fprintf(file, " file_id: %d block_len: %d\n", file_id, block_len); diff --git a/sql/log_event.h b/sql/log_event.h index 155da07bebd..1031b940528 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -435,6 +435,7 @@ public: bool use_rli_only_for_errors); #else void print(FILE* file, bool short_form = 0, char* last_db = 0); + void print(FILE* file, bool short_form, char* last_db, bool commented); #endif Load_log_event(const char* buf, int event_len, bool old_format); From d43a347db179f4601465debc3bfd3cfbb87d1528 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 17:00:36 +0200 Subject: [PATCH 048/282] Use my_b_append instead of my_b_write on a SEQ_READ_APPEND cache, when we write the first 4 bytes of the relay log. Indeed comments in mysys/mf_iocache.c say we must always use my_b_append for such a cache. This *could* avoid a very rare assertion failure which is: 030524 19:32:38 Slave SQL thread initialized, starting replication in log 'FIRST' at position 0, relay log '/ users/gbichot/4.1.1/mysql-test/var/log/slave-relay-bin.000001' position: 4 030524 19:32:38 next log '/users/gbichot/4.1.1/mysql-test/var/log/slave-relay-bin.000002' is currently active mysqld: mf_iocache.c:701: _my_b_seq_read: Assertion `pos_in_file == info->end_of_file' failed. and which seemed to happen always when the SQL thread and/or the I/O thread were at position 4 in a relay log. include/my_sys.h: moving a function from log_event.cc so that it can be widely used mysys/mf_iocache.c: moving a function from log_event.cc so that it can be widely used sql/log.cc: my_b_write should not be used on a SEQ_READ_APPEND cache, one should use my_b_append (otherwise there could be some locking problems). sql/log_event.cc: moved to mysys/mf_iocache.c for wider use. A typo. --- include/my_sys.h | 2 ++ mysys/mf_iocache.c | 14 ++++++++++++++ sql/log.cc | 2 +- sql/log_event.cc | 16 +--------------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/include/my_sys.h b/include/my_sys.h index 7f8b8a80a1c..9f4b91c8bf6 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -677,6 +677,8 @@ extern int _my_b_get(IO_CACHE *info); extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count); extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count); extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count); +extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count); + extern int my_block_write(IO_CACHE *info, const byte *Buffer, uint Count, my_off_t pos); extern int _flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index 0f35ee048bb..d96d4c0db3c 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -988,6 +988,20 @@ end: } +int my_b_safe_write(IO_CACHE *info, const byte *Buffer, uint Count) +{ + /* + Sasha: We are not writing this with the ? operator to avoid hitting + a possible compiler bug. At least gcc 2.95 cannot deal with + several layers of ternary operators that evaluated comma(,) operator + expressions inside - I do have a test case if somebody wants it + */ + if (info->type == SEQ_READ_APPEND) + return my_b_append(info, Buffer, Count); + return my_b_write(info, Buffer, Count); +} + + /* Write a block to disk where part of the data may be inside the record buffer. As all write calls to the data goes through the cache, diff --git a/sql/log.cc b/sql/log.cc index 17715620950..4dce26d23ea 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -263,7 +263,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, an extension for the binary log files. In this case we write a standard header to it. */ - if (my_b_write(&log_file, (byte*) BINLOG_MAGIC, BIN_LOG_HEADER_SIZE)) + if (my_b_safe_write(&log_file, (byte*) BINLOG_MAGIC, BIN_LOG_HEADER_SIZE)) goto err; bytes_written += BIN_LOG_HEADER_SIZE; write_file_name_to_index_file=1; diff --git a/sql/log_event.cc b/sql/log_event.cc index 591ebf2b5d8..2a1669737f8 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -26,20 +26,6 @@ #include -inline int my_b_safe_write(IO_CACHE* file, const byte *buf, - int len) -{ - /* - Sasha: We are not writing this with the ? operator to avoid hitting - a possible compiler bug. At least gcc 2.95 cannot deal with - several layers of ternary operators that evaluated comma(,) operator - expressions inside - I do have a test case if somebody wants it - */ - if (file->type == SEQ_READ_APPEND) - return my_b_append(file, buf,len); - return my_b_write(file, buf,len); -} - #ifdef MYSQL_CLIENT static void pretty_print_str(FILE* file, char* str, int len) { @@ -2039,7 +2025,7 @@ Slave: load data infile on table '%s' at log position %s in log \ err=ER(sql_errno); } slave_print_error(rli,sql_errno,"\ -Error '%s' running lOAD DATA INFILE on table '%s'. Default database: '%s'", +Error '%s' running LOAD DATA INFILE on table '%s'. Default database: '%s'", err, (char*)table_name, print_slave_db_safe(db)); free_root(&thd->mem_root,0); return 1; From be9744817cc44b3e2f93d1b0b86ffeec261a0480 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 18:34:44 +0200 Subject: [PATCH 049/282] - Added a missing directory variable definition to the Bootstrap script. Build-tools/Bootstrap: - defined $opt_directory to be the present working directory. No clue how this worked before... --- Build-tools/Bootstrap | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Build-tools/Bootstrap b/Build-tools/Bootstrap index 4a2e6f284f2..94446d9880f 100755 --- a/Build-tools/Bootstrap +++ b/Build-tools/Bootstrap @@ -33,6 +33,7 @@ $opt_docdir= $PWD . "/mysqldoc"; $opt_build_command= undef; $opt_changelog= undef; $opt_delete= undef; +$opt_directory= $PWD; $opt_dry_run= undef; $opt_export_only= undef; $opt_help= $opt_verbose= 0; @@ -104,7 +105,7 @@ defined($REPO=$ARGV[0]) || print_help("Please enter the BK repository to be used system ("bk help > /dev/null") == 0 or &abort("Cannot execute BitKeeper binary!"); system ("bk root $REPO > /dev/null 2>&1") == 0 or &abort("$REPO does not seem to be a valid BK repository!"); -if (($opt_directory ne ".") && (!-d $opt_directory && !$opt_dry_run)) +if (($opt_directory ne $PWD) && (!-d $opt_directory && !$opt_dry_run)) { &abort("Could not find target directory \"$opt_directory\"!"); } From 018e7524b8bcb6c2c909cf12361385eba7589413 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 19 Aug 2003 20:53:45 +0200 Subject: [PATCH 050/282] FT-NL bugfix - ignore words that appear more than in 2mio rows to avoid tree overflow. optimization: abort search for common (>50% rows) words earlier. --- myisam/ft_nlq_search.c | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) diff --git a/myisam/ft_nlq_search.c b/myisam/ft_nlq_search.c index 95ff700f815..f426b88d77d 100644 --- a/myisam/ft_nlq_search.c +++ b/myisam/ft_nlq_search.c @@ -67,12 +67,9 @@ static int FT_SUPERDOC_cmp(void* cmp_arg __attribute__((unused)), static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) { uint keylen, r, doc_cnt; -#ifdef EVAL_RUN - uint cnt; - double sum, sum2, suml; -#endif /* EVAL_RUN */ FT_SUPERDOC sdoc, *sptr; TREE_ELEMENT *selem; + double gweight=1; #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT float tmp_weight; #else @@ -84,42 +81,27 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) word->weight=LWS_FOR_QUERY; keylen=_ft_make_key(aio->info,aio->keynr,(char*) aio->keybuff,word,0); -#ifdef EVAL_RUN - keylen-=1+HA_FT_WLEN; -#else /* EVAL_RUN */ keylen-=HA_FT_WLEN; -#endif /* EVAL_RUN */ -#ifdef EVAL_RUN - sum=sum2=suml= -#endif /* EVAL_RUN */ doc_cnt=0; r=_mi_search(aio->info, aio->keyinfo, aio->keybuff, keylen, SEARCH_FIND | SEARCH_PREFIX, aio->key_root); aio->info->update|= HA_STATE_AKTIV; /* for _mi_test_if_changed() */ - while (!r) + while (!r && gweight) { if (_mi_compare_text(aio->charset, aio->info->lastkey,keylen, aio->keybuff,keylen,0)) break; #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT -#ifdef EVAL_RUN - mi_float4get(tmp_weight,aio->info->lastkey+keylen+1); -#else /* EVAL_RUN */ mi_float4get(tmp_weight,aio->info->lastkey+keylen); -#endif /* EVAL_RUN */ #else #error #endif if(tmp_weight==0) DBUG_RETURN(doc_cnt); /* stopword, doc_cnt should be 0 */ -#ifdef EVAL_RUN - cnt=*(byte *)(aio->info->lastkey+keylen); -#endif /* EVAL_RUN */ - sdoc.doc.dpos=aio->info->lastpos; /* saving document matched into dtree */ @@ -137,11 +119,10 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) sptr->tmp_weight=tmp_weight; doc_cnt++; -#ifdef EVAL_RUN - sum +=cnt; - sum2+=cnt*cnt; - suml+=cnt*log(cnt); -#endif /* EVAL_RUN */ + + gweight=word->weight*GWS_IN_USE; + if (gweight < 0 || doc_cnt > 2000000) + gweight=0; if (_mi_test_if_changed(aio->info) == 0) r=_mi_search_next(aio->info, aio->keyinfo, aio->info->lastkey, @@ -152,13 +133,9 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio) aio->info->lastkey_length, SEARCH_BIGGER, aio->key_root); } - if (doc_cnt) - { - word->weight*=GWS_IN_USE; - if (word->weight < 0) - word->weight=0; - } + word->weight=gweight; + DBUG_RETURN(0); } From e3541b8a97f74f4dbdbe8a34b445106e3cefdcc4 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 03:38:31 +0400 Subject: [PATCH 051/282] Fix for BUG#1086. Now we don't preserve event's log_pos through log-slave-updates since this causes unexpected values in Exec_master_log_pos in A->B->C replication setup, synchronization problems in master_pos_wait()... Still this brokes some functionality in sql/repl_failsafe.cc (but this file is not used now) mysql-test/r/rpl_log.result: SHOW BINLOG EVENTS for binlog on slave should give the same Orig_log_pos and Pos values sql/log_event.cc: Do not propagate our master's log pos to our bin log sql/repl_failsafe.cc: Added comment about broken SHOW NEW MASTER sql/slave.cc: Do not propagate our master's log pos to our bin log sql/sql_class.cc: THD::log_pos is no longer needed sql/sql_class.h: THD::log_pos is no longer needed sql/sql_parse.cc: Added comment about broken SHOW NEW MASTER --- mysql-test/r/rpl_log.result | 12 ++++++------ sql/log_event.cc | 5 ++--- sql/repl_failsafe.cc | 15 +++++++++++++++ sql/slave.cc | 1 - sql/sql_class.cc | 1 - sql/sql_class.h | 1 - sql/sql_parse.cc | 1 + 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index 2798d1a9fab..fbec0542e4b 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -85,15 +85,15 @@ slave-bin.001 263 Query 1 263 use test; drop table t1 slave-bin.001 311 Query 1 311 use test; create table t1 (word char(20) not null) slave-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 slave-bin.001 1065 Exec_load 1 1056 ;file_id=1 -slave-bin.001 1088 Query 1 1079 use test; drop table t1 -slave-bin.001 1136 Query 1 4 use test; create table t5 (a int) -slave-bin.001 1194 Query 1 62 use test; drop table t5 +slave-bin.001 1088 Query 1 1088 use test; drop table t1 +slave-bin.001 1136 Query 1 1136 use test; create table t5 (a int) +slave-bin.001 1194 Query 1 1194 use test; drop table t5 slave-bin.001 1242 Rotate 2 1242 slave-bin.002;pos=4 show binlog events in 'slave-bin.002' from 4; Log_name Pos Event_type Server_id Orig_log_pos Info -slave-bin.002 4 Query 1 110 use test; create table t1 (n int) -slave-bin.002 62 Query 1 168 use test; insert into t1 values (1) -slave-bin.002 122 Query 1 228 use test; drop table t1 +slave-bin.002 4 Query 1 4 use test; create table t1 (n int) +slave-bin.002 62 Query 1 62 use test; insert into t1 values (1) +slave-bin.002 122 Query 1 122 use test; drop table t1 show slave status; Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space 127.0.0.1 root MASTER_PORT 1 master-bin.002 276 slave-relay-bin.003 211 master-bin.002 Yes Yes 0 0 276 211 diff --git a/sql/log_event.cc b/sql/log_event.cc index 2a1669737f8..a4883599b2b 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -119,12 +119,11 @@ const char* Log_event::get_type_str() #ifndef MYSQL_CLIENT Log_event::Log_event(THD* thd_arg, uint16 flags_arg, bool using_trans) - :temp_buf(0), exec_time(0), cached_event_len(0), flags(flags_arg), - thd(thd_arg) + :log_pos(0), temp_buf(0), exec_time(0), cached_event_len(0), + flags(flags_arg), thd(thd_arg) { server_id = thd->server_id; when = thd->start_time; - log_pos = thd->log_pos; cache_stmt= (using_trans && (thd->options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))); } diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 0a5f90617d1..dc3f3c87dde 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -249,6 +249,18 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg) /* Impossible */ } +/* + Before 4.0.15 we had a member of THD called log_pos, it was meant for + failsafe replication code in repl_failsafe.cc which is disabled until + it is reworked. Event's log_pos used to be preserved through + log-slave-updates to make code in repl_failsafe.cc work (this + function, SHOW NEW MASTER); but on the other side it caused unexpected + values in Exec_master_log_pos in A->B->C replication setup, + synchronization problems in master_pos_wait(), ... So we + (Dmitri & Guilhem) removed it. + + So for now this function is broken. +*/ int translate_master(THD* thd, LEX_MASTER_INFO* mi, char* errmsg) { @@ -414,6 +426,9 @@ static Slave_log_event* find_slave_event(IO_CACHE* log, return (Slave_log_event*)ev; } +/* + This function is broken now. See comment for translate_master(). + */ int show_new_master(THD* thd) { diff --git a/sql/slave.cc b/sql/slave.cc index 85a9bc0d49e..145144072c9 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2253,7 +2253,6 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) if (!ev->when) ev->when = time(NULL); ev->thd = thd; - thd->log_pos = ev->log_pos; exec_res = ev->exec_event(rli); DBUG_ASSERT(rli->sql_thd==thd); delete ev; diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 2a65291c273..132e0d7745f 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -125,7 +125,6 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0), where="field list"; server_id = ::server_id; slave_net = 0; - log_pos = 0; command=COM_CONNECT; set_query_id=1; db_access=NO_ACCESS; diff --git a/sql/sql_class.h b/sql/sql_class.h index c4511652b23..49a364856eb 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -472,7 +472,6 @@ public: */ ulong slave_proxy_id; NET* slave_net; // network connection from slave -> m. - my_off_t log_pos; /* Used by the sys_var class to store temporary values */ union diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1d82ac6110b..1479a611b5a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1458,6 +1458,7 @@ mysql_execute_command(void) { if (check_global_access(thd, REPL_SLAVE_ACL)) goto error; + /* This query don't work now. See comment in repl_failsafe.cc */ #ifndef WORKING_NEW_MASTER net_printf(&thd->net, ER_NOT_SUPPORTED_YET, "SHOW NEW MASTER"); res= 1; From 2d2db894d4d0875927509cc334530196405800de Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 12:27:06 +0200 Subject: [PATCH 052/282] comment added --- client/mysqltest.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index f5afa0fa0df..62b5df6c90d 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -221,6 +221,13 @@ const char *command_names[]= "connection", "query", "connect", + /* the difference between sleep and real_sleep is that sleep will use + the delay from command line (--sleep) if there is one. + real_sleep always uses delay from it's argument. + the logic is that sometimes delays are cpu-dependent (and --sleep + can be used to set this delay. real_sleep is used for cpu-independent + delays + */ "sleep", "real_sleep", "inc", From 22ad5163e99357e0d976203e3476e6d9cb22590f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 15:33:21 +0300 Subject: [PATCH 053/282] item_func.h: Fix for a bug with LEAST() in WHERE clause ha_innodb.cc: Fix for a configure bug multi_update.result, multi_update.test: Fix for the update with NULL's in the result set sql_update.cc: Fix for the update with NULL's in the result set Fix for the update with NULL's in the result set Fix for the update with NULL's in the result set sql/sql_update.cc: Fix for the update with NULL's in the result set Fix for the update with NULL's in the result set Fix for the update with NULL's in the result set mysql-test/t/multi_update.test: Fix for the update with NULL's in the result set mysql-test/r/multi_update.result: Fix for the update with NULL's in the result set sql/ha_innodb.cc: Fix for a configure bug sql/item_func.h: Fix for a bug with LEAST() in WHERE clause --- mysql-test/r/multi_update.result | 9 +++++++++ mysql-test/t/multi_update.test | 7 +++++++ sql/ha_innodb.cc | 1 - sql/item_func.h | 1 + sql/sql_update.cc | 6 +++++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index 91170f885a3..350cea420b6 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -318,3 +318,12 @@ create table t2(Z varchar(15)); insert into t2(Z) select concat(a.a,b.a,c.a,d.a) from t1 as a, t1 as b, t1 as c, t1 as d; update t2,t3 set Z =param_scenario_costs; drop table t1,t2,t3; +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1),(2,1),(3,1); +insert into t2 values (1,1), (3,1); +update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL; +select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL; +a b a b +2 2 NULL NULL +drop table t1,t2; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 0c7ad6160ee..7aa4e74cec0 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -260,3 +260,10 @@ create table t2(Z varchar(15)); insert into t2(Z) select concat(a.a,b.a,c.a,d.a) from t1 as a, t1 as b, t1 as c, t1 as d; update t2,t3 set Z =param_scenario_costs; drop table t1,t2,t3; +create table t1 (a int, b int); +create table t2 (a int, b int); +insert into t1 values (1,1),(2,1),(3,1); +insert into t2 values (1,1), (3,1); +update t1 left join t2 on t1.a=t2.a set t1.b=2, t2.b=2 where t1.b=1 and t2.b=1 or t2.a is NULL; +select t1.a, t1.b,t2.a, t2.b from t1 left join t2 on t1.a=t2.a where t1.b=1 and t2.b=1 or t2.a is NULL; +drop table t1,t2; diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 09119a4eb54..3619fefdd1b 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -28,7 +28,6 @@ InnoDB */ #include "mysql_priv.h" #include "slave.h" -#include "sql_cache.h" #ifdef HAVE_INNOBASE_DB #include diff --git a/sql/item_func.h b/sql/item_func.h index 8a4cace0b87..bccd0ca7adb 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -514,6 +514,7 @@ public: void fix_length_and_dec(); enum Item_result result_type () const { return cmp_type; } unsigned int size_of() { return sizeof(*this);} + table_map not_null_tables() const { return 0; } }; class Item_func_min :public Item_func_min_max diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 3179c8e0f24..2f3f917a962 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -575,6 +575,7 @@ multi_update::initialize_tables(JOIN *join) { TABLE *table=table_ref->table; uint cnt= table_ref->shared; + Item_field *If; List temp_fields= *fields_for_table[cnt]; ORDER group; @@ -598,7 +599,10 @@ multi_update::initialize_tables(JOIN *join) /* ok to be on stack as this is not referenced outside of this func */ Field_string offset(table->file->ref_length, 0, "offset", table, 1); - if (temp_fields.push_front(new Item_field(((Field *) &offset)))) + if (!(If=new Item_field(((Field *) &offset)))) + DBUG_RETURN(1); + If->maybe_null=0; + if (temp_fields.push_front(If)) DBUG_RETURN(1); /* Make an unique key over the first field to avoid duplicated updates */ From d140ed2d03a333ce5f4a043428be575771a62504 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 15:52:43 +0300 Subject: [PATCH 054/282] func_test.result, func_test.test: Test case for the LEAST() bug in LEFT JOIN mysql-test/t/func_test.test: Test case for the LEAST() bug in LEFT JOIN mysql-test/r/func_test.result: Test case for the LEAST() bug in LEFT JOIN --- mysql-test/r/func_test.result | 9 +++++++++ mysql-test/t/func_test.test | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/mysql-test/r/func_test.result b/mysql-test/r/func_test.result index 8cfae44b9dd..b9d75189146 100644 --- a/mysql-test/r/func_test.result +++ b/mysql-test/r/func_test.result @@ -55,3 +55,12 @@ select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1; select 1 and 0 or 2, 2 or 1 and 0; 1 and 0 or 2 2 or 1 and 0 1 1 +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) TYPE=MyISAM; +INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','\r\n\r\n \r\n \r\n \r\n \r\n
 \r\n

How \r\n To: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected.

\r\n
','\r\n \r\n \r\n \r\n \r\n\r\n \r\n
  \r\n \r\n

1. Select \r\n the On/Setup button to access the DynaVox Setup Menu.
\r\n 2. Select Button Features.
\r\n 3. Below the OK button is the Usage Counts button.
\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.
\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.
\r\n c. Select the Usage Counts Option Ring once and it will toggle \r\n to the alternative option.
\r\n 4. Once the correct setting has been chosen, select OK to leave the Button \r\n Features menu.
\r\n 5. Select OK out of the Setup menu and return to the communication \r\n page.

\r\n

For \r\n further information on Usage Counts, see the Button Features \r\n Menu Entry in the DynaVox/DynaMyte Reference Manual.

\r\n
',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL); +CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, rank smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) TYPE=MyISAM; +INSERT INTO t2 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Customer Support',1); +SELECT f_acc.rank, a1.rank, a2.rank FROM t1 LEFT JOIN t1 f1 ON (f1.access_id=1 AND f1.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a1 ON (a1.access_id = f1.access_id) LEFT JOIN t1 f2 ON (f2.access_id=3 AND f2.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a2 ON (a2.access_id = f2.access_id), t2 f_acc WHERE LEAST(a1.rank,a2.rank) = f_acc.rank; +rank rank rank +2 2 NULL +DROP TABLE t1,t2; diff --git a/mysql-test/t/func_test.test b/mysql-test/t/func_test.test index f5ad2e21c73..5e3785fb719 100644 --- a/mysql-test/t/func_test.test +++ b/mysql-test/t/func_test.test @@ -25,3 +25,10 @@ select 1 XOR 1, 1 XOR 0, 0 XOR 1, 0 XOR 0, NULL XOR 1, 1 XOR NULL, 0 XOR NULL; select 5 between 0 and 10 between 0 and 1,(5 between 0 and 10) between 0 and 1; select 1 and 2 between 2 and 10, 2 between 2 and 10 and 1; select 1 and 0 or 2, 2 or 1 and 0; +DROP TABLE IF EXISTS t1,t2; +CREATE TABLE t1 ( faq_group_id int(11) NOT NULL default '0', faq_id int(11) NOT NULL default '0', title varchar(240) default NULL, keywords text, description longblob, solution longblob, status tinyint(4) NOT NULL default '0', access_id smallint(6) default NULL, lang_id smallint(6) NOT NULL default '0', created datetime NOT NULL default '0000-00-00 00:00:00', updated datetime default NULL, last_access datetime default NULL, last_notify datetime default NULL, solved_count int(11) NOT NULL default '0', static_solved int(11) default NULL, solved_1 int(11) default NULL, solved_2 int(11) default NULL, solved_3 int(11) default NULL, solved_4 int(11) default NULL, solved_5 int(11) default NULL, expires datetime default NULL, notes text, assigned_to smallint(6) default NULL, assigned_group smallint(6) default NULL, last_edited_by smallint(6) default NULL, orig_ref_no varchar(15) binary default NULL, c$fundstate smallint(6) default NULL, c$contributor smallint(6) default NULL, UNIQUE KEY t1$faq_id (faq_id), KEY t1$group_id$faq_id (faq_group_id,faq_id), KEY t1$c$fundstate (c$fundstate) ) TYPE=MyISAM; +INSERT INTO t1 VALUES (82,82,'How to use the DynaVox Usage Counts Feature','usages count, number, corner, white, box, button','\r\n\r\n \r\n \r\n \r\n \r\n
 \r\n

How \r\n To: \r\n Display or Hide the Usage Counts to find out how many times each button is being selected.

\r\n
','\r\n \r\n \r\n \r\n \r\n\r\n \r\n
  \r\n \r\n

1. Select \r\n the On/Setup button to access the DynaVox Setup Menu.
\r\n 2. Select Button Features.
\r\n 3. Below the OK button is the Usage Counts button.
\r\n a. If it says \"Hidden\" then the Usage Counts will not be displayed.
\r\n b. If it says \"Displayed\" then the Usage Counts will be shown.
\r\n c. Select the Usage Counts Option Ring once and it will toggle \r\n to the alternative option.
\r\n 4. Once the correct setting has been chosen, select OK to leave the Button \r\n Features menu.
\r\n 5. Select OK out of the Setup menu and return to the communication \r\n page.

\r\n

For \r\n further information on Usage Counts, see the Button Features \r\n Menu Entry in the DynaVox/DynaMyte Reference Manual.

\r\n
',4,1,1,'2001-11-16 16:43:34','2002-11-25 12:09:43','2003-07-24 01:04:48',NULL,11,NULL,0,0,0,0,0,NULL,NULL,NULL,NULL,11,NULL,NULL,NULL); +CREATE TABLE t2 ( access_id smallint(6) NOT NULL default '0', name varchar(20) binary default NULL, rank smallint(6) NOT NULL default '0', KEY t2$access_id (access_id) ) TYPE=MyISAM; +INSERT INTO t2 VALUES (1,'Everyone',2),(2,'Help',3),(3,'Customer Support',1); +SELECT f_acc.rank, a1.rank, a2.rank FROM t1 LEFT JOIN t1 f1 ON (f1.access_id=1 AND f1.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a1 ON (a1.access_id = f1.access_id) LEFT JOIN t1 f2 ON (f2.access_id=3 AND f2.faq_group_id = t1.faq_group_id) LEFT JOIN t2 a2 ON (a2.access_id = f2.access_id), t2 f_acc WHERE LEAST(a1.rank,a2.rank) = f_acc.rank; +DROP TABLE t1,t2; From db2b279f70b9572fe713c9d80edca97d0247e400 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 16:14:01 +0300 Subject: [PATCH 055/282] sql_union.cc: Fix for SQL_CALC_FOUND_ROWS in UNION's sql/sql_union.cc: Fix for SQL_CALC_FOUND_ROWS in UNION's --- mysql-test/r/union.result | 56 ++++++++++++++++++++++++++++++++++++++- mysql-test/t/union.test | 16 +++++++++++ sql/sql_union.cc | 16 +++++++++-- 3 files changed, 85 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 51d9f2d17ca..50f689e3e4b 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -102,7 +102,7 @@ a b 2 b select found_rows(); found_rows() -6 +8 explain select a,b from t1 union all select a,b from t2; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 4 @@ -295,3 +295,57 @@ a b 5 f 6 e drop table t1,t2,t3,t4; +CREATE TABLE t1 ( `IdUser` int(11) NOT NULL default '0', `IdDirectMessage` int(11) NOT NULL default '0', `Readed` datetime default NULL, PRIMARY KEY (`IdUser`,`IdDirectMessage`), KEY `IdDirectMessage` (`IdDirectMessage`), ); +CREATE TABLE t2 ( `IdDirectMessage` int(11) NOT NULL default '0', `MessageData` text NOT NULL, `DateOfMessage` datetime default NULL, PRIMARY KEY (`IdDirectMessage`) ); +INSERT INTO t2 (`IdDirectMessage`, `MessageData`, `DateOfMessage`) VALUES (1,'Texto','2003-08-06 00:00:00'), (2,'Texto','2003-08-06 00:00:00'), (3,'Texto','2003-08-06 00:00:00'), (4,'Texto','2003-08-06 00:00:00'), (5,'Texto','2003-08-06 00:00:00'), (6,'Texto','2003-08-06 00:00:00'), (7,'Texto','2003-08-06 00:00:00'), (8,'Texto','2003-08-06 00:00:00'), (9,'Texto','2003-08-06 00:00:00'), (10,'Texto','2003-08-06 00:00:00'), (11,'Texto','2003-08-06 00:00:00'), (12,'Texto','2003-08-06 00:00:00'), (13,'Texto','2003-08-06 00:00:00'), (14,'Texto','2003-08-06 00:00:00'), (15,'Texto','2003-08-06 00:00:00'), (16,'Texto','2003-08-06 00:00:00'), (17,'Texto','2003-08-06 00:00:00'), (18,'Texto','2003-08-06 00:00:00'), (19,'Texto','2003-08-06 00:00:00'), (20,'Texto','2003-08-06 00:00:00'), (21,'Texto','2003-08-06 00:00:00'), (22,'Texto','2003-08-06 00:00:00'); +INSERT INTO t1 (`IdUser`, `IdDirectMessage`, `Readed`) VALUES (4,1,'2003-08-07 10:10:13'), (4,2,'2003-08-07 10:10:13'), (4,3,'2003-08-07 10:10:13'), (4,4,'2003-08-07 10:10:13'), (4,5,'2003-08-07 10:10:13'), (4,6,'2003-08-07 10:10:13'), (4,7,'2003-08-07 10:10:13'), (4,8,'2003-08-07 10:10:13'), (4,9,'2003-08-07 10:10:13'), (4,10,'2003-08-07 10:10:13'), (4,11,'2003-08-07 10:10:13'), (4,12,'2003-08-07 10:10:13'), (4,13,'2003-08-07 10:10:13'), (4,14,'2003-08-07 10:10:13'), (4,15,'2003-08-07 10:10:13'), (4,16,'2003-08-07 10:10:13'), (4,17,'2003-08-07 10:10:13'), (4,18,'2003-08-07 10:10:13'), (4,19,'2003-08-07 10:10:13'), (4,20,'2003-08-07 10:10:13'), (4,21,'2003-08-06 16:51:04'), (4,22,'2003-08-06 16:51:19'); +SELECT SQL_CALC_FOUND_ROWS t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND Readed Is NULL UNION SELECT t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND NOT (t1.Readed is NULL) ORDER BY DateOfMessage Limit 0,2; +IdDirectMessage MessageData DateOfMessage +1 Texto 2003-08-06 00:00:00 +2 Texto 2003-08-06 00:00:00 +SELECT FOUND_ROWS(); +FOUND_ROWS() +22 +SELECT SQL_CALC_FOUND_ROWS t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND Readed Is NULL UNION ALL SELECT t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND NOT (t1.Readed is NULL) ORDER BY DateOfMessage Limit 0,2; +IdDirectMessage MessageData DateOfMessage +1 Texto 2003-08-06 00:00:00 +2 Texto 2003-08-06 00:00:00 +SELECT FOUND_ROWS(); +FOUND_ROWS() +22 +SELECT SQL_CALC_FOUND_ROWS t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND Readed Is NULL limit 1 UNION SELECT t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND NOT (t1.Readed is NULL) ORDER BY DateOfMessage; +IdDirectMessage MessageData DateOfMessage +1 Texto 2003-08-06 00:00:00 +2 Texto 2003-08-06 00:00:00 +3 Texto 2003-08-06 00:00:00 +4 Texto 2003-08-06 00:00:00 +5 Texto 2003-08-06 00:00:00 +6 Texto 2003-08-06 00:00:00 +7 Texto 2003-08-06 00:00:00 +8 Texto 2003-08-06 00:00:00 +9 Texto 2003-08-06 00:00:00 +10 Texto 2003-08-06 00:00:00 +11 Texto 2003-08-06 00:00:00 +12 Texto 2003-08-06 00:00:00 +13 Texto 2003-08-06 00:00:00 +14 Texto 2003-08-06 00:00:00 +15 Texto 2003-08-06 00:00:00 +16 Texto 2003-08-06 00:00:00 +17 Texto 2003-08-06 00:00:00 +18 Texto 2003-08-06 00:00:00 +19 Texto 2003-08-06 00:00:00 +20 Texto 2003-08-06 00:00:00 +21 Texto 2003-08-06 00:00:00 +22 Texto 2003-08-06 00:00:00 +SELECT FOUND_ROWS(); +FOUND_ROWS() +22 +drop table t2,t1; +CREATE TABLE t1 ( sid int(11) NOT NULL default '0', nazwa char(10) NOT NULL default '', PRIMARY KEY (sid) ) TYPE=MyISAM; +CREATE TABLE t2 ( id int(11) NOT NULL default '0', link int(11) default NULL, bubu char(10) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM; +INSERT INTO t2 VALUES (1,2,'keke'); +SELECT bubu, nazwa, bubu FROM t2 LEFT JOIN t1 ON sid = link WHERE id=1 UNION SELECT 'bu', null, 'bu'; +bubu nazwa bubu +keke NULL keke +bu NULL bu +drop table t1,t2; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 5f7eba83755..502086d0e82 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -170,3 +170,19 @@ insert into t3 (select a,b from t1) union (select a,b from t2) limit 2; select * from t3; select * from t4; drop table t1,t2,t3,t4; +CREATE TABLE t1 ( `IdUser` int(11) NOT NULL default '0', `IdDirectMessage` int(11) NOT NULL default '0', `Readed` datetime default NULL, PRIMARY KEY (`IdUser`,`IdDirectMessage`), KEY `IdDirectMessage` (`IdDirectMessage`), ); +CREATE TABLE t2 ( `IdDirectMessage` int(11) NOT NULL default '0', `MessageData` text NOT NULL, `DateOfMessage` datetime default NULL, PRIMARY KEY (`IdDirectMessage`) ); +INSERT INTO t2 (`IdDirectMessage`, `MessageData`, `DateOfMessage`) VALUES (1,'Texto','2003-08-06 00:00:00'), (2,'Texto','2003-08-06 00:00:00'), (3,'Texto','2003-08-06 00:00:00'), (4,'Texto','2003-08-06 00:00:00'), (5,'Texto','2003-08-06 00:00:00'), (6,'Texto','2003-08-06 00:00:00'), (7,'Texto','2003-08-06 00:00:00'), (8,'Texto','2003-08-06 00:00:00'), (9,'Texto','2003-08-06 00:00:00'), (10,'Texto','2003-08-06 00:00:00'), (11,'Texto','2003-08-06 00:00:00'), (12,'Texto','2003-08-06 00:00:00'), (13,'Texto','2003-08-06 00:00:00'), (14,'Texto','2003-08-06 00:00:00'), (15,'Texto','2003-08-06 00:00:00'), (16,'Texto','2003-08-06 00:00:00'), (17,'Texto','2003-08-06 00:00:00'), (18,'Texto','2003-08-06 00:00:00'), (19,'Texto','2003-08-06 00:00:00'), (20,'Texto','2003-08-06 00:00:00'), (21,'Texto','2003-08-06 00:00:00'), (22,'Texto','2003-08-06 00:00:00'); +INSERT INTO t1 (`IdUser`, `IdDirectMessage`, `Readed`) VALUES (4,1,'2003-08-07 10:10:13'), (4,2,'2003-08-07 10:10:13'), (4,3,'2003-08-07 10:10:13'), (4,4,'2003-08-07 10:10:13'), (4,5,'2003-08-07 10:10:13'), (4,6,'2003-08-07 10:10:13'), (4,7,'2003-08-07 10:10:13'), (4,8,'2003-08-07 10:10:13'), (4,9,'2003-08-07 10:10:13'), (4,10,'2003-08-07 10:10:13'), (4,11,'2003-08-07 10:10:13'), (4,12,'2003-08-07 10:10:13'), (4,13,'2003-08-07 10:10:13'), (4,14,'2003-08-07 10:10:13'), (4,15,'2003-08-07 10:10:13'), (4,16,'2003-08-07 10:10:13'), (4,17,'2003-08-07 10:10:13'), (4,18,'2003-08-07 10:10:13'), (4,19,'2003-08-07 10:10:13'), (4,20,'2003-08-07 10:10:13'), (4,21,'2003-08-06 16:51:04'), (4,22,'2003-08-06 16:51:19'); +SELECT SQL_CALC_FOUND_ROWS t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND Readed Is NULL UNION SELECT t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND NOT (t1.Readed is NULL) ORDER BY DateOfMessage Limit 0,2; +SELECT FOUND_ROWS(); +SELECT SQL_CALC_FOUND_ROWS t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND Readed Is NULL UNION ALL SELECT t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND NOT (t1.Readed is NULL) ORDER BY DateOfMessage Limit 0,2; +SELECT FOUND_ROWS(); +SELECT SQL_CALC_FOUND_ROWS t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND Readed Is NULL limit 1 UNION SELECT t2.* FROM t2 INNER JOIN t1 ON t2.IdDirectMessage = t1.IdDirectMessage WHERE IdUser = 4 AND NOT (t1.Readed is NULL) ORDER BY DateOfMessage; +SELECT FOUND_ROWS(); +drop table t2,t1; +CREATE TABLE t1 ( sid int(11) NOT NULL default '0', nazwa char(10) NOT NULL default '', PRIMARY KEY (sid) ) TYPE=MyISAM; +CREATE TABLE t2 ( id int(11) NOT NULL default '0', link int(11) default NULL, bubu char(10) NOT NULL default '', PRIMARY KEY (id) ) TYPE=MyISAM; +INSERT INTO t2 VALUES (1,2,'keke'); +SELECT bubu, nazwa, bubu FROM t2 LEFT JOIN t1 ON sid = link WHERE id=1 UNION SELECT 'bu', null, 'bu'; +drop table t1,t2; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index bd7bc7027d3..81a4806ab65 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -32,7 +32,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) List item_list; TABLE *table; int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0; - int res; + int res, add_rows=0; bool found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; TABLE_LIST result_table_list; TABLE_LIST *first_table=(TABLE_LIST *)lex->select_lex.table_list.first; @@ -135,6 +135,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) union_result->tmp_table_param=&tmp_table_param; for (sl= &lex->select_lex; sl; sl=sl->next) { + unsigned int rows; lex->select=sl; thd->offset_limit=sl->offset_limit; thd->select_limit=sl->select_limit+sl->offset_limit; @@ -142,6 +143,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) thd->select_limit= HA_POS_ERROR; // no limit if (thd->select_limit == HA_POS_ERROR || sl->braces) sl->options&= ~OPTION_FOUND_ROWS; + else if (found_rows_for_union) + { + rows= thd->select_limit; + sl->options|= OPTION_FOUND_ROWS; + } res=mysql_select(thd, (describe && sl->linkage==NOT_A_SELECT) ? first_table : (TABLE_LIST*) sl->table_list.first, @@ -155,6 +161,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) sl->options | thd->options | SELECT_NO_UNLOCK | ((describe) ? SELECT_DESCRIBE : 0), union_result); + if (found_rows_for_union && !sl->braces && sl->options & OPTION_FOUND_ROWS) + add_rows+= (thd->limit_found_rows > rows) ? thd->limit_found_rows - rows : 0; if (res) goto exit; } @@ -210,7 +218,11 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) (ORDER*) NULL, NULL, (ORDER*) NULL, thd->options, result); if (found_rows_for_union && !res) - thd->limit_found_rows = (ulonglong)table->file->records; + { + thd->limit_found_rows= table->file->records; + if (!last_sl->braces) + thd->limit_found_rows+= add_rows; + } } } From de5d47c35d426a84cb0fd453dfdc17012dc8ba55 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 16:25:44 +0300 Subject: [PATCH 056/282] Fixed some varnings from valgrind Set min value of max_allowed_packet to 1024 Fixed problem with UNION's without braces and SQL_CALC_FOUND_ROWS, LIMIT #,# and ORDER BY...LIMIT include/m_string.h: Added memcpy_overlap() to avoid warnings when using valgrind on memcpy(A,A,...) myisam/mi_create.c: Fixed comment myisam/mi_search.c: Fix warning from valgrind myisam/mi_write.c: Indentation fix mysql-test/mysql-test-run.sh: Add options handled by general skip- option mysql-test/r/packet.result: Update results after change to mysqld (min max_allowed_packet length is now 1024) mysql-test/r/union.result: Added testing of UNION with SQL_CALC_FOUND_ROWS mysql-test/t/packet.test: Update results after change to mysqld (min max_allowed_packet length is now 1024) mysql-test/t/union.test: Added testing of UNION with SQL_CALC_FOUND_ROWS sql/field.cc: Fix to remove waarning from valgrind sql/ha_innodb.cc: Remove wrong include file sql/item_cmpfunc.cc: Safety fix to handle EOM conditions in IN sql/item_sum.cc: Fixed prototype for update_field() (argument was alwys 0) sql/item_sum.h: Fixed prototype for update_field() (argument was alwys 0) sql/item_uniq.h: Fixed prototype for update_field() (argument was alwys 0) sql/log.cc: Indentation fix sql/mysqld.cc: Set min value of max_allowed_packet to 1024 (to avoid it getting set to 0) sql/net_serv.cc: Indentation changes + trivial optimization sql/sql_select.cc: Fixed prototype for update_field() (argument was alwys 0) sql/sql_union.cc: Fixed problem with UNION's without braces and - SQL_CALC_FOUND_ROWS - LIMIT #,# - ORDER BY ... LIMIT --- include/m_string.h | 12 ++++ myisam/mi_create.c | 2 +- myisam/mi_search.c | 10 ++- myisam/mi_write.c | 1 - mysql-test/mysql-test-run.sh | 6 -- mysql-test/r/packet.result | 12 ++-- mysql-test/r/union.result | 127 ++++++++++++++++++++++++++++++++++- mysql-test/t/packet.test | 6 +- mysql-test/t/union.test | 56 ++++++++++++++- sql/field.cc | 7 +- sql/ha_innodb.cc | 1 - sql/item_cmpfunc.cc | 17 +++-- sql/item_sum.cc | 67 ++++++++---------- sql/item_sum.h | 32 ++++----- sql/item_uniq.h | 2 +- sql/log.cc | 3 +- sql/mysqld.cc | 2 +- sql/net_serv.cc | 27 +++++--- sql/sql_select.cc | 2 +- sql/sql_union.cc | 65 ++++++++++++++---- 20 files changed, 342 insertions(+), 115 deletions(-) diff --git a/include/m_string.h b/include/m_string.h index c6943613b1a..eae0e8f3f94 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -119,6 +119,18 @@ extern void bmove_allign(gptr dst,const gptr src,uint len); #define bmove512(A,B,C) memcpy(A,B,C) #endif +#ifdef HAVE_purify +#include +#define memcpy_overlap(A,B,C) \ +DBUG_ASSERT((A) == (B) || ((A)+(C)) <= (B) || ((B)+(C)) <= (A)); \ +bmove((byte*) key,(byte*) from,(size_t) length); +#else +#define memcpy_overlap(A,B,C) \ +DBUG_ASSERT((A) == (B) || ((A)+(C)) <= (B) || ((B)+(C)) <= (A)); \ +memcpy((A), (B), (C)) +#endif /* HAVE_purify */ + + /* Prototypes for string functions */ #if !defined(bfill) && !defined(HAVE_BFILL) diff --git a/myisam/mi_create.c b/myisam/mi_create.c index 9082c2b0d95..9f39c6f522e 100644 --- a/myisam/mi_create.c +++ b/myisam/mi_create.c @@ -286,7 +286,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, keydef->seg[0].type == (int) HA_KEYTYPE_NUM) keydef->seg[0].flag&= ~HA_SPACE_PACK; - /* Only use HA_PACK_KEY if the first segment is a variable length key */ + /* Only use HA_PACK_KEY when first segment is a variable length key */ if (!(keydef->seg[0].flag & (HA_SPACE_PACK | HA_BLOB_PART | HA_VAR_LENGTH))) { diff --git a/myisam/mi_search.c b/myisam/mi_search.c index 32db69144d8..423b15ff8f7 100644 --- a/myisam/mi_search.c +++ b/myisam/mi_search.c @@ -1218,9 +1218,10 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, register uchar **page_pos, register uchar *key) { reg1 MI_KEYSEG *keyseg; - uchar *start_key,*page=*page_pos,*page_end,*from,*from_end; + uchar *start_key,*page,*page_end,*from,*from_end; uint length,tmp; + page= *page_pos; page_end=page+MI_MAX_KEY_BUFF+1; start_key=key; @@ -1276,7 +1277,9 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, length-=tmp; from=page; from_end=page_end; } - memcpy((byte*) key,(byte*) from,(size_t) length); + DBUG_PRINT("info",("key: %lx from: %lx length: %u", + key, from, length)); + memcpy_overlap((byte*) key, (byte*) from, (size_t) length); key+=length; from+=length; } @@ -1998,6 +2001,9 @@ _mi_calc_bin_pack_key_length(MI_KEYDEF *keyinfo,uint nod_flag,uchar *next_key, uint length,key_length,ref_length; s_temp->totlength=key_length=_mi_keylength(keyinfo,key)+nod_flag; +#ifdef HAVE_purify + s_temp->n_length= s_temp->n_ref_length=0; /* For valgrind */ +#endif s_temp->key=key; s_temp->prev_key=org_key; if (prev_key) /* If not first key in block */ diff --git a/myisam/mi_write.c b/myisam/mi_write.c index d39bbbf5fc7..40e2f301fce 100644 --- a/myisam/mi_write.c +++ b/myisam/mi_write.c @@ -887,4 +887,3 @@ void mi_end_bulk_insert(MI_INFO *info) info->bulk_insert=0; } } - diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 55adc3d88fc..bf5546483d3 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -253,12 +253,6 @@ while test $# -gt 0; do --start-and-exit) START_AND_EXIT=1 ;; - --skip-innodb) - EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-innodb" - EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-innodb" ;; - --skip-bdb) - EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-bdb" - EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-bdb" ;; --skip-rpl) NO_SLAVE=1 ;; --skip-test=*) SKIP_TEST=`$ECHO "$1" | $SED -e "s;--skip-test=;;"`;; --do-test=*) DO_TEST=`$ECHO "$1" | $SED -e "s;--do-test=;;"`;; diff --git a/mysql-test/r/packet.result b/mysql-test/r/packet.result index e994e4d63da..6733f2b142e 100644 --- a/mysql-test/r/packet.result +++ b/mysql-test/r/packet.result @@ -5,12 +5,12 @@ set net_buffer_length=100; SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; len 1024 -select repeat('a',200); -repeat('a',200) +select repeat('a',2000); +repeat('a',2000) NULL select @@net_buffer_length, @@max_allowed_packet; @@net_buffer_length @@max_allowed_packet -1024 80 +1024 1024 SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; Got a packet bigger than 'max_allowed_packet' set global max_allowed_packet=default; @@ -20,6 +20,6 @@ set net_buffer_length=default; SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; len 100 -select length(repeat('a',200)); -length(repeat('a',200)) -200 +select length(repeat('a',2000)); +length(repeat('a',2000)) +2000 diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 51d9f2d17ca..9899b8279e2 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -102,7 +102,7 @@ a b 2 b select found_rows(); found_rows() -6 +8 explain select a,b from t1 union all select a,b from t2; table type possible_keys key key_len ref rows Extra t1 ALL NULL NULL NULL NULL 4 @@ -295,3 +295,128 @@ a b 5 f 6 e drop table t1,t2,t3,t4; +create table t1 (a int); +insert into t1 values (1),(2),(3); +create table t2 (a int); +insert into t2 values (3),(4),(5); +(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2) LIMIT 1; +a +1 +select found_rows(); +found_rows() +6 +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2) LIMIT 2; +a +1 +3 +select found_rows(); +found_rows() +4 +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2); +a +1 +3 +4 +5 +select found_rows(); +found_rows() +4 +(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1); +a +1 +2 +3 +3 +select found_rows(); +found_rows() +4 +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1; +a +1 +select found_rows(); +found_rows() +4 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2; +a +1 +3 +select found_rows(); +found_rows() +6 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION all SELECT * FROM t2 LIMIT 2; +a +1 +2 +select found_rows(); +found_rows() +6 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2; +a +1 +2 +select found_rows(); +found_rows() +6 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 100; +a +1 +2 +3 +4 +5 +select found_rows(); +found_rows() +6 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 100 UNION SELECT * FROM t2; +a +1 +2 +3 +4 +5 +select found_rows(); +found_rows() +5 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2; +a +1 +3 +4 +5 +select found_rows(); +found_rows() +6 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2 LIMIT 2; +a +1 +3 +select found_rows(); +found_rows() +6 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2,2; +a +3 +4 +select found_rows(); +found_rows() +6 +SELECT SQL_CALC_FOUND_ROWS * FROM t1 limit 2,2 UNION SELECT * FROM t2; +a +3 +4 +5 +select found_rows(); +found_rows() +5 +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1; +a +5 +(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4; +a +5 +4 +3 +3 +(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1; +Wrong usage/placement of 'SQL_CALC_FOUND_ROWS' +drop table t1,t2; diff --git a/mysql-test/t/packet.test b/mysql-test/t/packet.test index 5c4e7efcaf3..cbeaa04ca52 100644 --- a/mysql-test/t/packet.test +++ b/mysql-test/t/packet.test @@ -12,8 +12,8 @@ set global net_buffer_length=100; set net_buffer_length=100; # Have to be > 1024 as min value of net_buffer_length is 1024 SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; -# Should return NULL as 200 is bigger than max_allowed_packet -select repeat('a',200); +# Should return NULL as 2000 is bigger than max_allowed_packet +select repeat('a',2000); # # Connection 2 should get error for too big packets @@ -28,4 +28,4 @@ set max_allowed_packet=default; set global net_buffer_length=default; set net_buffer_length=default; SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len; -select length(repeat('a',200)); +select length(repeat('a',2000)); diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 5f7eba83755..ea7bdb4ee1b 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -16,7 +16,7 @@ select 0,'#' union select a,b from t1 union all select a,b from t2 union select select a,b from t1 union select a,b from t1; select 't1',b,count(*) from t1 group by b UNION select 't2',b,count(*) from t2 group by b; -#test alternate syntax for unions +# Test alternate syntax for unions (select a,b from t1 limit 2) union all (select a,b from t2 order by a) limit 4; (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1); (select a,b from t1 limit 2) union all (select a,b from t2 order by a limit 1) order by b desc; @@ -170,3 +170,57 @@ insert into t3 (select a,b from t1) union (select a,b from t2) limit 2; select * from t3; select * from t4; drop table t1,t2,t3,t4; + +# +# Test of SQL_CALC_FOUND_ROW handling +# +create table t1 (a int); +insert into t1 values (1),(2),(3); +create table t2 (a int); +insert into t2 values (3),(4),(5); + +# Test global limits +(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2) LIMIT 1; +select found_rows(); +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2) LIMIT 2; +select found_rows(); + +# Test cases where found_rows() should return number of returned rows +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION all (SELECT * FROM t2); +select found_rows(); +(SELECT SQL_CALC_FOUND_ROWS * FROM t1) UNION all (SELECT * FROM t2 LIMIT 1); +select found_rows(); +(SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1) UNION SELECT * FROM t2 LIMIT 1; +select found_rows(); + +# In these case found_rows() should work +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION all SELECT * FROM t2 LIMIT 2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION all SELECT * FROM t2 LIMIT 2; +select found_rows(); + +# The following examples will not be exact +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 100; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 100 UNION SELECT * FROM t2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 LIMIT 1 UNION SELECT * FROM t2 LIMIT 2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 UNION SELECT * FROM t2 LIMIT 2,2; +select found_rows(); +SELECT SQL_CALC_FOUND_ROWS * FROM t1 limit 2,2 UNION SELECT * FROM t2; +select found_rows(); + +# Test some limits with ORDER BY +SELECT * FROM t1 UNION SELECT * FROM t2 ORDER BY a desc LIMIT 1; +(SELECT * FROM t1 ORDER by a) UNION ALL (SELECT * FROM t2 ORDER BY a) ORDER BY A desc LIMIT 4; + +# Wrong usage +--error 1234 +(SELECT * FROM t1) UNION all (SELECT SQL_CALC_FOUND_ROWS * FROM t2) LIMIT 1; + +drop table t1,t2; diff --git a/sql/field.cc b/sql/field.cc index e56d53b1bda..592252bb294 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4147,8 +4147,11 @@ void Field_blob::store(const char *from,uint len) } } #endif /* USE_TIS620 */ - value.copy(from,len); - from=value.ptr(); + if (from != value.ptr()) // For valgrind + { + value.copy(from, len); + from= value.ptr(); + } #ifdef USE_TIS620 my_free(th_ptr,MYF(MY_ALLOW_ZERO_PTR)); #endif diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 09119a4eb54..3619fefdd1b 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -28,7 +28,6 @@ InnoDB */ #include "mysql_priv.h" #include "slave.h" -#include "sql_cache.h" #ifdef HAVE_INNOBASE_DB #include diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 8c58c58a67d..7415fc5b98e 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1045,15 +1045,18 @@ void Item_func_in::fix_length_and_dec() array= new in_double(arg_count); break; } - uint j=0; - for (uint i=0 ; i < arg_count ; i++) + if (array && !(current_thd->fatal_error)) // If not EOM { - array->set(j,args[i]); - if (!args[i]->null_value) // Skip NULL values - j++; + uint j=0; + for (uint i=0 ; i < arg_count ; i++) + { + array->set(j,args[i]); + if (!args[i]->null_value) // Skip NULL values + j++; + } + if ((array->used_count=j)) + array->sort(); } - if ((array->used_count=j)) - array->sort(); } else { diff --git a/sql/item_sum.cc b/sql/item_sum.cc index d88894d4fb4..08385bb9ca6 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -300,15 +300,15 @@ void Item_sum_std::reset_field() } } -void Item_sum_std::update_field(int offset) +void Item_sum_std::update_field() { double nr,old_nr,old_sqr; longlong field_count; char *res=result_field->ptr; - float8get(old_nr,res+offset); - float8get(old_sqr,res+offset+sizeof(double)); - field_count=sint8korr(res+offset+sizeof(double)*2); + float8get(old_nr, res); + float8get(old_sqr, res+sizeof(double)); + field_count=sint8korr(res+sizeof(double)*2); nr=args[0]->val(); if (!args[0]->null_value) @@ -619,12 +619,12 @@ void Item_sum_bit::reset_field() ** calc next value and merge it with field_value */ -void Item_sum_sum::update_field(int offset) +void Item_sum_sum::update_field() { double old_nr,nr; char *res=result_field->ptr; - float8get(old_nr,res+offset); + float8get(old_nr,res); nr=args[0]->val(); if (!args[0]->null_value) { @@ -635,12 +635,12 @@ void Item_sum_sum::update_field(int offset) } -void Item_sum_count::update_field(int offset) +void Item_sum_count::update_field() { longlong nr; char *res=result_field->ptr; - nr=sint8korr(res+offset); + nr=sint8korr(res); if (!args[0]->maybe_null) nr++; else @@ -653,14 +653,14 @@ void Item_sum_count::update_field(int offset) } -void Item_sum_avg::update_field(int offset) +void Item_sum_avg::update_field() { double nr,old_nr; longlong field_count; char *res=result_field->ptr; - float8get(old_nr,res+offset); - field_count=sint8korr(res+offset+sizeof(double)); + float8get(old_nr,res); + field_count=sint8korr(res+sizeof(double)); nr=args[0]->val(); if (!args[0]->null_value) @@ -673,78 +673,66 @@ void Item_sum_avg::update_field(int offset) int8store(res,field_count); } -void Item_sum_hybrid::update_field(int offset) +void Item_sum_hybrid::update_field() { if (hybrid_type == STRING_RESULT) - min_max_update_str_field(offset); + min_max_update_str_field(); else if (hybrid_type == INT_RESULT) - min_max_update_int_field(offset); + min_max_update_int_field(); else - min_max_update_real_field(offset); + min_max_update_real_field(); } void -Item_sum_hybrid::min_max_update_str_field(int offset) +Item_sum_hybrid::min_max_update_str_field() { String *res_str=args[0]->val_str(&value); - if (args[0]->null_value) - result_field->copy_from_tmp(offset); // Use old value - else + if (!args[0]->null_value) { res_str->strip_sp(); - result_field->ptr+=offset; // Get old max/min result_field->val_str(&tmp_value,&tmp_value); - result_field->ptr-=offset; if (result_field->is_null() || (cmp_sign * (binary ? stringcmp(res_str,&tmp_value) : sortcmp(res_str,&tmp_value)) < 0)) result_field->store(res_str->ptr(),res_str->length()); - else - { // Use old value - char *res=result_field->ptr; - memcpy(res,res+offset,result_field->pack_length()); - } result_field->set_notnull(); } } void -Item_sum_hybrid::min_max_update_real_field(int offset) +Item_sum_hybrid::min_max_update_real_field() { double nr,old_nr; - result_field->ptr+=offset; old_nr=result_field->val_real(); nr=args[0]->val(); if (!args[0]->null_value) { - if (result_field->is_null(offset) || + if (result_field->is_null(0) || (cmp_sign > 0 ? old_nr > nr : old_nr < nr)) old_nr=nr; result_field->set_notnull(); } - else if (result_field->is_null(offset)) + else if (result_field->is_null(0)) result_field->set_null(); - result_field->ptr-=offset; result_field->store(old_nr); } void -Item_sum_hybrid::min_max_update_int_field(int offset) +Item_sum_hybrid::min_max_update_int_field() { longlong nr,old_nr; - result_field->ptr+=offset; old_nr=result_field->val_int(); nr=args[0]->val_int(); if (!args[0]->null_value) { - if (result_field->is_null(offset)) + if (result_field->is_null(0)) old_nr=nr; else { @@ -757,30 +745,29 @@ Item_sum_hybrid::min_max_update_int_field(int offset) } result_field->set_notnull(); } - else if (result_field->is_null(offset)) + else if (result_field->is_null(0)) result_field->set_null(); - result_field->ptr-=offset; result_field->store(old_nr); } -void Item_sum_or::update_field(int offset) +void Item_sum_or::update_field() { ulonglong nr; char *res=result_field->ptr; - nr=uint8korr(res+offset); + nr=uint8korr(res); nr|= (ulonglong) args[0]->val_int(); int8store(res,nr); } -void Item_sum_and::update_field(int offset) +void Item_sum_and::update_field() { ulonglong nr; char *res=result_field->ptr; - nr=uint8korr(res+offset); + nr=uint8korr(res); nr&= (ulonglong) args[0]->val_int(); int8store(res,nr); } diff --git a/sql/item_sum.h b/sql/item_sum.h index 2369b5d1d7e..5189566fdfb 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -56,7 +56,7 @@ public: virtual void reset()=0; virtual bool add()=0; virtual void reset_field()=0; - virtual void update_field(int offset)=0; + virtual void update_field()=0; virtual bool keep_field_type(void) const { return 0; } virtual void fix_length_and_dec() { maybe_null=1; null_value=1; } virtual const char *func_name() const { return "?"; } @@ -116,7 +116,7 @@ class Item_sum_sum :public Item_sum_num bool add(); double val(); void reset_field(); - void update_field(int offset); + void update_field(); void no_rows_in_result() {} const char *func_name() const { return "sum"; } unsigned int size_of() { return sizeof(*this);} @@ -141,7 +141,7 @@ class Item_sum_count :public Item_sum_int void make_const(longlong count_arg) { count=count_arg; used_table_cache=0; } longlong val_int(); void reset_field(); - void update_field(int offset); + void update_field(); const char *func_name() const { return "count"; } unsigned int size_of() { return sizeof(*this);} }; @@ -193,7 +193,7 @@ class Item_sum_count_distinct :public Item_sum_int bool add(); longlong val_int(); void reset_field() { return ;} // Never called - void update_field(int offset) { return ; } // Never called + void update_field() { return ; } // Never called const char *func_name() const { return "count_distinct"; } bool setup(THD *thd); void no_rows_in_result() {} @@ -235,7 +235,7 @@ class Item_sum_avg :public Item_sum_num bool add(); double val(); void reset_field(); - void update_field(int offset); + void update_field(); Item *result_item(Field *field) { return new Item_avg_field(this); } const char *func_name() const { return "avg"; } @@ -273,7 +273,7 @@ class Item_sum_std :public Item_sum_num bool add(); double val(); void reset_field(); - void update_field(int offset); + void update_field(); Item *result_item(Field *field) { return new Item_std_field(this); } const char *func_name() const { return "std"; } @@ -316,10 +316,10 @@ class Item_sum_hybrid :public Item_sum void make_const() { used_table_cache=0; } bool keep_field_type(void) const { return 1; } enum Item_result result_type () const { return hybrid_type; } - void update_field(int offset); - void min_max_update_str_field(int offset); - void min_max_update_real_field(int offset); - void min_max_update_int_field(int offset); + void update_field(); + void min_max_update_str_field(); + void min_max_update_real_field(); + void min_max_update_int_field(); unsigned int size_of() { return sizeof(*this);} }; @@ -371,7 +371,7 @@ class Item_sum_or :public Item_sum_bit public: Item_sum_or(Item *item_par) :Item_sum_bit(item_par,LL(0)) {} bool add(); - void update_field(int offset); + void update_field(); const char *func_name() const { return "bit_or"; } unsigned int size_of() { return sizeof(*this);} }; @@ -382,7 +382,7 @@ class Item_sum_and :public Item_sum_bit public: Item_sum_and(Item *item_par) :Item_sum_bit(item_par, ~(ulonglong) LL(0)) {} bool add(); - void update_field(int offset); + void update_field(); const char *func_name() const { return "bit_and"; } unsigned int size_of() { return sizeof(*this);} }; @@ -414,7 +414,7 @@ public: void reset(); bool add(); void reset_field() {}; - void update_field(int offset_arg) {}; + void update_field() {}; unsigned int size_of() { return sizeof(*this);} }; @@ -482,7 +482,7 @@ class Item_sum_udf_float :public Item_sum_num double val() { return 0.0; } void reset() {} bool add() { return 0; } - void update_field(int offset) {} + void update_field() {} }; @@ -497,7 +497,7 @@ public: double val() { return 0; } void reset() {} bool add() { return 0; } - void update_field(int offset) {} + void update_field() {} }; @@ -515,7 +515,7 @@ public: enum Sumfunctype sum_func () const { return UDF_SUM_FUNC; } void reset() {} bool add() { return 0; } - void update_field(int offset) {} + void update_field() {} }; #endif /* HAVE_DLOPEN */ diff --git a/sql/item_uniq.h b/sql/item_uniq.h index cc087832f49..de239d3a8ec 100644 --- a/sql/item_uniq.h +++ b/sql/item_uniq.h @@ -42,7 +42,7 @@ public: void reset() {} bool add() { return 0; } void reset_field() {} - void update_field(int offset) {} + void update_field() {} bool fix_fields(THD *thd,struct st_table_list *tlist) { return 0;} unsigned int size_of() { return sizeof(*this);} }; diff --git a/sql/log.cc b/sql/log.cc index 4dce26d23ea..7e12297d8ae 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -263,7 +263,8 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, an extension for the binary log files. In this case we write a standard header to it. */ - if (my_b_safe_write(&log_file, (byte*) BINLOG_MAGIC, BIN_LOG_HEADER_SIZE)) + if (my_b_safe_write(&log_file, (byte*) BINLOG_MAGIC, + BIN_LOG_HEADER_SIZE)) goto err; bytes_written += BIN_LOG_HEADER_SIZE; write_file_name_to_index_file=1; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index d9ba97ad11a..b90ab1a4a3a 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -3833,7 +3833,7 @@ replicating a LOAD DATA INFILE command", "Max packetlength to send/receive from to server.", (gptr*) &global_system_variables.max_allowed_packet, (gptr*) &max_system_variables.max_allowed_packet, 0, GET_ULONG, - REQUIRED_ARG, 1024*1024L, 80, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, + REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE, "Can be used to restrict the total size used to cache a multi-transaction query.", (gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0, diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 13f786e0e75..8f0d659daf2 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -215,10 +215,12 @@ int net_flush(NET *net) *****************************************************************************/ /* -** Write a logical packet with packet header -** Format: Packet length (3 bytes), packet number(1 byte) -** When compression is used a 3 byte compression length is added -** NOTE: If compression is used the original package is modified! + Write a logical packet with packet header + Format: Packet length (3 bytes), packet number(1 byte) + When compression is used a 3 byte compression length is added + + NOTE + If compression is used the original package is modified! */ int @@ -315,8 +317,8 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) The cached buffer can be sent as it is with 'net_flush()'. In this code we have to be careful to not send a packet longer than - MAX_PACKET_LENGTH to net_real_write() if we are using the compressed protocol - as we store the length of the compressed packet in 3 bytes. + MAX_PACKET_LENGTH to net_real_write() if we are using the compressed + protocol as we store the length of the compressed packet in 3 bytes. RETURN 0 ok @@ -821,20 +823,23 @@ my_net_read(NET *net) { /* We are using the compressed protocol */ - ulong buf_length= net->buf_length; - ulong start_of_packet= net->buf_length - net->remain_in_buf; - ulong first_packet_offset=start_of_packet; + ulong buf_length; + ulong start_of_packet; + ulong first_packet_offset; uint read_length, multi_byte_packet=0; if (net->remain_in_buf) { + buf_length= net->buf_length; // Data left in old packet + first_packet_offset= start_of_packet= (net->buf_length - + net->remain_in_buf); /* Restore the character that was overwritten by the end 0 */ - net->buff[start_of_packet]=net->save_char; + net->buff[start_of_packet]= net->save_char; } else { /* reuse buffer, as there is nothing in it that we need */ - buf_length=start_of_packet=first_packet_offset=0; + buf_length= start_of_packet= first_packet_offset= 0; } for (;;) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 7922af04ea8..560f5f5dc79 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -7224,7 +7224,7 @@ update_tmptable_sum_func(Item_sum **func_ptr, { Item_sum *func; while ((func= *(func_ptr++))) - func->update_field(0); + func->update_field(); } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index bd7bc7027d3..34acd79f18b 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -31,9 +31,10 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ORDER *order; List item_list; TABLE *table; - int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0; int res; - bool found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; + ulonglong add_rows= 0; + ulong found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; + ulong describe= lex->select_lex.options & SELECT_DESCRIBE; TABLE_LIST result_table_list; TABLE_LIST *first_table=(TABLE_LIST *)lex->select_lex.table_list.first; TMP_TABLE_PARAM tmp_table_param; @@ -135,14 +136,44 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) union_result->tmp_table_param=&tmp_table_param; for (sl= &lex->select_lex; sl; sl=sl->next) { + ha_rows records_at_start; lex->select=sl; - thd->offset_limit=sl->offset_limit; - thd->select_limit=sl->select_limit+sl->offset_limit; + /* Don't use offset for the last union if there is no braces */ + if (sl != lex_sl) + { + thd->offset_limit= sl->offset_limit; + thd->select_limit=sl->select_limit+sl->offset_limit; + } + else + { + thd->offset_limit= 0; + /* + We can't use LIMIT at this stage if we are using ORDER BY for the + whole query + */ + thd->select_limit= HA_POS_ERROR; + if (! sl->order_list.first) + thd->select_limit= sl->select_limit+sl->offset_limit; + } if (thd->select_limit < sl->select_limit) thd->select_limit= HA_POS_ERROR; // no limit + + /* + When using braces, SQL_CALC_FOUND_ROWS affects the whole query. + We don't calculate found_rows() per union part + */ if (thd->select_limit == HA_POS_ERROR || sl->braces) sl->options&= ~OPTION_FOUND_ROWS; + else + { + /* + We are doing an union without braces. In this case + SQL_CALC_FOUND_ROWS should be done on all sub parts + */ + sl->options|= found_rows_for_union; + } + records_at_start= table->file->records; res=mysql_select(thd, (describe && sl->linkage==NOT_A_SELECT) ? first_table : (TABLE_LIST*) sl->table_list.first, sl->item_list, @@ -153,10 +184,23 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) sl->having, (ORDER*) NULL, sl->options | thd->options | SELECT_NO_UNLOCK | - ((describe) ? SELECT_DESCRIBE : 0), + describe, union_result); if (res) goto exit; + /* Needed for the following test and for records_at_start in next loop */ + table->file->info(HA_STATUS_VARIABLE); + if (found_rows_for_union & sl->options) + { + /* + This is a union without braces. Remember the number of rows that could + also have been part of the result set. + We get this from the difference of between total number of possible + rows and actual rows added to the temporary table. + */ + add_rows+= (ulonglong) (thd->limit_found_rows - (table->file->records - + records_at_start)); + } } if (union_result->flush()) { @@ -172,19 +216,14 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) /* Create a list of fields in the temporary table */ List_iterator it(item_list); Field **field; -#if 0 - List ftfunc_list; - ftfunc_list.empty(); -#else thd->lex.select_lex.ftfunc_list.empty(); -#endif for (field=table->field ; *field ; field++) { (void) it++; (void) it.replace(new Item_field(*field)); } - if (!thd->fatal_error) // Check if EOM + if (!thd->fatal_error) // Check if EOM { if (lex_sl) { @@ -209,8 +248,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) item_list, NULL, (describe) ? 0 : order, (ORDER*) NULL, NULL, (ORDER*) NULL, thd->options, result); - if (found_rows_for_union && !res) - thd->limit_found_rows = (ulonglong)table->file->records; + if (!res) + thd->limit_found_rows = (ulonglong)table->file->records + add_rows; } } From 83374580c2e9f1cc919ac5d8babb0e1f8ddd40fc Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 17:16:07 +0300 Subject: [PATCH 057/282] Fixed problem with undefined assert symbol --- include/m_string.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/include/m_string.h b/include/m_string.h index eae0e8f3f94..eac1552f8c1 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -125,9 +125,7 @@ extern void bmove_allign(gptr dst,const gptr src,uint len); DBUG_ASSERT((A) == (B) || ((A)+(C)) <= (B) || ((B)+(C)) <= (A)); \ bmove((byte*) key,(byte*) from,(size_t) length); #else -#define memcpy_overlap(A,B,C) \ -DBUG_ASSERT((A) == (B) || ((A)+(C)) <= (B) || ((B)+(C)) <= (A)); \ -memcpy((A), (B), (C)) +#define memcpy_overlap(A,B,C) memcpy((A), (B), (C)) #endif /* HAVE_purify */ From 478caeb478cbc40ba52e13761adb3a05915c9d96 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 16:32:00 +0200 Subject: [PATCH 058/282] sleep instead of system sleep --- mysql-test/t/rpl_relayrotate.test | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mysql-test/t/rpl_relayrotate.test b/mysql-test/t/rpl_relayrotate.test index 3df55eea57d..3f315ba9365 100644 --- a/mysql-test/t/rpl_relayrotate.test +++ b/mysql-test/t/rpl_relayrotate.test @@ -40,7 +40,7 @@ start slave; # Usually it stops when the SQL thread is around the 15th relay log. # We cannot use MASTER_POS_WAIT() as master's position # increases only when the slave executes the COMMIT. -system sleep 1; +sleep 1; stop slave; # We suppose the SQL thread stopped before COMMIT. # If so the transaction was rolled back From c1e6d2d1bfe7ba4fe7e8ae766fca161233d4890e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 20:16:37 +0300 Subject: [PATCH 059/282] sql_union.cc: Merge fix sql/sql_union.cc: Merge fix --- sql/sql_union.cc | 52 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 17 deletions(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 81a4806ab65..fe13261b454 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -31,9 +31,10 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ORDER *order; List item_list; TABLE *table; - int describe=(lex->select_lex.options & SELECT_DESCRIBE) ? 1 : 0; - int res, add_rows=0; - bool found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; + int res; + ulonglong add_rows= 0; + ulong found_rows_for_union= lex->select_lex.options & OPTION_FOUND_ROWS; + ulong describe= lex->select_lex.options & SELECT_DESCRIBE; TABLE_LIST result_table_list; TABLE_LIST *first_table=(TABLE_LIST *)lex->select_lex.table_list.first; TMP_TABLE_PARAM tmp_table_param; @@ -135,19 +136,29 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) union_result->tmp_table_param=&tmp_table_param; for (sl= &lex->select_lex; sl; sl=sl->next) { - unsigned int rows; + ha_rows records_at_start; lex->select=sl; - thd->offset_limit=sl->offset_limit; + /* Don't use offset for the last union if there is no braces */ + thd->offset_limit= sl != lex_sl ? sl->offset_limit : 0; thd->select_limit=sl->select_limit+sl->offset_limit; if (thd->select_limit < sl->select_limit) thd->select_limit= HA_POS_ERROR; // no limit + /* + When using braces, SQL_CALC_FOUND_ROWS affects the whole query. + We don't calculate found_rows() per union part + */ if (thd->select_limit == HA_POS_ERROR || sl->braces) sl->options&= ~OPTION_FOUND_ROWS; - else if (found_rows_for_union) + else { - rows= thd->select_limit; - sl->options|= OPTION_FOUND_ROWS; + /* + We are doing an union without braces. In this case + SQL_CALC_FOUND_ROWS should be done on all sub parts + */ + sl->options|= found_rows_for_union; } + + records_at_start= table->file->records; res=mysql_select(thd, (describe && sl->linkage==NOT_A_SELECT) ? first_table : (TABLE_LIST*) sl->table_list.first, @@ -159,12 +170,23 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) sl->having, (ORDER*) NULL, sl->options | thd->options | SELECT_NO_UNLOCK | - ((describe) ? SELECT_DESCRIBE : 0), + describe, union_result); - if (found_rows_for_union && !sl->braces && sl->options & OPTION_FOUND_ROWS) - add_rows+= (thd->limit_found_rows > rows) ? thd->limit_found_rows - rows : 0; if (res) goto exit; + /* Needed for the following test and for records_at_start in next loop */ + table->file->info(HA_STATUS_VARIABLE); + if (found_rows_for_union & sl->options) + { + /* + This is a union without braces. Remember the number of rows that could + also have been part of the result set. + We get this from the difference of between total number of possible + rows and actual rows added to the temporary table. + */ + add_rows+= (ulonglong) (thd->limit_found_rows - (table->file->records - + records_at_start)); + } } if (union_result->flush()) { @@ -217,12 +239,8 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) item_list, NULL, (describe) ? 0 : order, (ORDER*) NULL, NULL, (ORDER*) NULL, thd->options, result); - if (found_rows_for_union && !res) - { - thd->limit_found_rows= table->file->records; - if (!last_sl->braces) - thd->limit_found_rows+= add_rows; - } + if (!res) + thd->limit_found_rows = (ulonglong)table->file->records + add_rows; } } From 1542fffb345693565a32f9a2e6a1eba980aeaaf2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 20 Aug 2003 23:24:45 +0200 Subject: [PATCH 060/282] First commit for fixing BUG#1100 "LOAD DATA INFILE is badly filtered by binlog-*-db rules". There will probably be a second final one to merge Dmitri's changes to rpl_log.result and mine. 2 new tests: rpl_loaddata_rule_m : test of logging of LOAD DATA INFILE when the master has binlog-*-db rules, rpl_loaddata_rule_s : test of logging of LOAD DATA INFILE when the slave has binlog-*-db rules and --log-slave-updates. mysql-test/r/rpl_loaddata.result: Test that logging of LOAD DATA INFILE is done on the slave mysql-test/t/rpl_loaddata.test: Test that logging of LOAD DATA is done on the slave sql/log.cc: debug info sql/log_event.cc: * Append_block, Exec_load and Delete_file now have a member 'db' like Create_file. This member is filled by mysql_load(). It is used for filtering by binlog-*-db rules, that's all. It's not written to the binlog, and so can't be read from the binlog. In other words, that's temporary info which is stored in the event and lost when it is written and deleted. * Better error messages in Append_block et al. events. * The slave now logs (log-slave-updates) the Create_file et al. events in mysql_load() (they are not directly copied from the events in the relay log, because this prevented filtering by binlog-*-db rules). Before, mysql_load() in the slave did no logging, now it does the logging, as in any regular thread. sql/log_event.h: New member 'db' for Append_block et al. events. sql/slave.cc: Removed useless code. Why was it useless: - CREATE_FILE_EVENT is not defined in 3.23. It appeared in 4.0. - in queue_old_event(), which is called only if the master is 3.23, we had a case CREATE_FILE_EVENT: so this case can be removed. - this case was the only caller of process_io_create_file() so this function can be removed. sql/sql_load.cc: Pass the db to events, so that they can be well filtered. sql/sql_repl.cc: Pass the db to events so that they can be well filtered. --- mysql-test/r/rpl_loaddata.result | 4 + mysql-test/r/rpl_loaddata_rule_m.result | 14 +++ mysql-test/r/rpl_loaddata_rule_s.result | 14 +++ mysql-test/t/rpl_loaddata.test | 17 +++ mysql-test/t/rpl_loaddata_rule_m-master.opt | 1 + mysql-test/t/rpl_loaddata_rule_m.test | 18 ++++ mysql-test/t/rpl_loaddata_rule_s-slave.opt | 1 + mysql-test/t/rpl_loaddata_rule_s.test | 20 ++++ sql/log.cc | 1 + sql/log_event.cc | 69 ++++++------- sql/log_event.h | 26 ++++- sql/slave.cc | 109 -------------------- sql/sql_load.cc | 4 +- sql/sql_repl.cc | 2 +- 14 files changed, 148 insertions(+), 152 deletions(-) create mode 100644 mysql-test/r/rpl_loaddata_rule_m.result create mode 100644 mysql-test/r/rpl_loaddata_rule_s.result create mode 100644 mysql-test/t/rpl_loaddata_rule_m-master.opt create mode 100644 mysql-test/t/rpl_loaddata_rule_m.test create mode 100644 mysql-test/t/rpl_loaddata_rule_s-slave.opt create mode 100644 mysql-test/t/rpl_loaddata_rule_s.test diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index 05bdad0fb84..b42f78f01bd 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -4,6 +4,7 @@ reset master; reset slave; drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; slave start; +reset master; create table t1(a int not null auto_increment, b int, primary key(a) ); load data infile '../../std_data/rpl_loaddata.dat' into table t1; create temporary table t2 (day date,id int(9),category enum('a','b','c'),name varchar(60)); @@ -19,6 +20,9 @@ day id category name 2003-02-22 2461 b a a a @ %  ' " a 2003-03-22 2161 c asdf 2003-04-22 2416 a bbbbb +show binlog events from 898; +Log_name Pos Event_type Server_id Orig_log_pos Info +slave-bin.001 898 Query 1 895 use test; insert into t3 select * from t2 drop table t1; drop table t2; drop table t3; diff --git a/mysql-test/r/rpl_loaddata_rule_m.result b/mysql-test/r/rpl_loaddata_rule_m.result new file mode 100644 index 00000000000..8d8ed749c71 --- /dev/null +++ b/mysql-test/r/rpl_loaddata_rule_m.result @@ -0,0 +1,14 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +reset master; +create database test2; +create table t1(a int, b int, unique(b)); +use test2; +load data infile '../../std_data/rpl_loaddata.dat' into table test.t1; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +drop database test2; diff --git a/mysql-test/r/rpl_loaddata_rule_s.result b/mysql-test/r/rpl_loaddata_rule_s.result new file mode 100644 index 00000000000..a84368501a9 --- /dev/null +++ b/mysql-test/r/rpl_loaddata_rule_s.result @@ -0,0 +1,14 @@ +slave stop; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +slave start; +reset master; +create table t1(a int, b int, unique(b)); +load data infile '../../std_data/rpl_loaddata.dat' into table test.t1; +select count(*) from t1; +count(*) +2 +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index 0a07dd7549b..65e07aaa823 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -12,6 +12,10 @@ source include/master-slave.inc; +connection slave; +reset master; +connection master; + create table t1(a int not null auto_increment, b int, primary key(a) ); load data infile '../../std_data/rpl_loaddata.dat' into table t1; @@ -27,6 +31,16 @@ sync_with_master; select * from t1; select * from t3; +# We want to be sure that LOAD DATA is in the slave's binlog. +# But we can't simply read this binlog, because the file_id is uncertain (would +# cause test failures). So instead, we test if the binlog looks long enough to +# contain LOAD DATA. That is, I (Guilhem) have done SHOW BINLOG EVENTS on my +# machine, saw that the last event is 'create table t3' and is at position 898 +# when things go fine. If LOAD DATA was not logged, the binlog would be shorter +# than 898 bytes and there would be an error in SHOW BINLOG EVENTS. Of course, +# if someone changes the content of '../../std_data/rpl_loaddata2.dat', 898 will +# have to be changed too. +show binlog events from 898; connection master; @@ -38,6 +52,9 @@ create table t1(a int, b int, unique(b)); save_master_pos; connection slave; sync_with_master; + +# See if slave stops when there's a duplicate entry for key error in LOAD DATA + insert into t1 values(1,10); connection master; diff --git a/mysql-test/t/rpl_loaddata_rule_m-master.opt b/mysql-test/t/rpl_loaddata_rule_m-master.opt new file mode 100644 index 00000000000..9d4a8f0b95e --- /dev/null +++ b/mysql-test/t/rpl_loaddata_rule_m-master.opt @@ -0,0 +1 @@ +--binlog_ignore_db=test diff --git a/mysql-test/t/rpl_loaddata_rule_m.test b/mysql-test/t/rpl_loaddata_rule_m.test new file mode 100644 index 00000000000..18f295f8ce2 --- /dev/null +++ b/mysql-test/t/rpl_loaddata_rule_m.test @@ -0,0 +1,18 @@ +# See if the master logs LOAD DATA INFILE correctly when binlog_*_db rules +# exist. +# This is for BUG#1100 (LOAD DATA INFILE was half-logged). + +source include/master-slave.inc; +connection slave; +reset master; + +# Test logging on master + +connection master; +# 'test' is the current database +create database test2; +create table t1(a int, b int, unique(b)); +use test2; +load data infile '../../std_data/rpl_loaddata.dat' into table test.t1; +show binlog events from 79; # should be nothing +drop database test2; diff --git a/mysql-test/t/rpl_loaddata_rule_s-slave.opt b/mysql-test/t/rpl_loaddata_rule_s-slave.opt new file mode 100644 index 00000000000..9d4a8f0b95e --- /dev/null +++ b/mysql-test/t/rpl_loaddata_rule_s-slave.opt @@ -0,0 +1 @@ +--binlog_ignore_db=test diff --git a/mysql-test/t/rpl_loaddata_rule_s.test b/mysql-test/t/rpl_loaddata_rule_s.test new file mode 100644 index 00000000000..1ea4f6825f5 --- /dev/null +++ b/mysql-test/t/rpl_loaddata_rule_s.test @@ -0,0 +1,20 @@ +# See if the slave logs (in its own binlog, with --log-slave-updates) a +# replicated LOAD DATA INFILE correctly when it has binlog_*_db rules. +# This is for BUG#1100 (LOAD DATA INFILE was half-logged). + +source include/master-slave.inc; +connection slave; +reset master; + +connection master; +# 'test' is the current database +create table t1(a int, b int, unique(b)); +load data infile '../../std_data/rpl_loaddata.dat' into table test.t1; + +# Test logging on slave; + +save_master_pos; +connection slave; +sync_with_master; +select count(*) from t1; # check that LOAD was replicated +show binlog events from 79; # should be nothing diff --git a/sql/log.cc b/sql/log.cc index 4dce26d23ea..e03eec184b5 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1067,6 +1067,7 @@ bool MYSQL_LOG::write(Log_event* event_info) #else IO_CACHE *file = &log_file; #endif + DBUG_PRINT("info",("event type=%d",event_info->get_type_code())); /* In the future we need to add to the following if tests like "do the involved tables match (to be implemented) diff --git a/sql/log_event.cc b/sql/log_event.cc index 2a1669737f8..407da85c38a 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1606,11 +1606,12 @@ void Create_file_log_event::pack_info(String* packet) #endif #ifndef MYSQL_CLIENT -Append_block_log_event::Append_block_log_event(THD* thd_arg, char* block_arg, +Append_block_log_event::Append_block_log_event(THD* thd_arg, const char* db_arg, + char* block_arg, uint block_len_arg, bool using_trans) :Log_event(thd_arg,0, using_trans), block(block_arg), - block_len(block_len_arg), file_id(thd_arg->file_id) + block_len(block_len_arg), file_id(thd_arg->file_id), db(db_arg) { } #endif @@ -1654,8 +1655,9 @@ void Append_block_log_event::pack_info(String* packet) net_store_data(packet, buf1); } -Delete_file_log_event::Delete_file_log_event(THD* thd_arg, bool using_trans) - :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id) +Delete_file_log_event::Delete_file_log_event(THD* thd_arg, const char* db_arg, + bool using_trans) + :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id), db(db_arg) { } #endif @@ -1700,8 +1702,9 @@ void Delete_file_log_event::pack_info(String* packet) #ifndef MYSQL_CLIENT -Execute_load_log_event::Execute_load_log_event(THD* thd_arg, bool using_trans) - :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id) +Execute_load_log_event::Execute_load_log_event(THD* thd_arg, const char* db_arg, + bool using_trans) + :Log_event(thd_arg, 0, using_trans), file_id(thd_arg->file_id), db(db_arg) { } #endif @@ -1905,7 +1908,19 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli, DBUG_ASSERT(thd->query == 0); thd->query = 0; // Should not be needed thd->query_error = 0; - + + /* + We test replicate_*_db rules. Note that we have already prepared the file to + load, even if we are going to ignore and delete it now. So it is possible + that we did a lot of disk writes for nothing. In other words, a big LOAD + DATA INFILE on the master will still consume a lot of space on the slave + (space in the relay log + space of temp files: twice the space of the file + to load...) even if it will finally be ignored. + TODO: fix this; this can be done by testing rules in + Create_file_log_event::exec_event() and then discarding Append_block and + al. Another way is do the filtering in the I/O thread (more efficient: no + disk writes at all). + */ if (db_ok(thd->db, replicate_do_db, replicate_ignore_db)) { thd->set_time((time_t)when); @@ -2210,7 +2225,7 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) init_io_cache(&file, fd, IO_SIZE, WRITE_CACHE, (my_off_t)0, 0, MYF(MY_WME|MY_NABP))) { - slave_print_error(rli,my_errno, "Could not open file '%s'", fname_buf); + slave_print_error(rli,my_errno, "Error in Create_file event: could not open file '%s'", fname_buf); goto err; } @@ -2221,7 +2236,7 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) if (write_base(&file)) { strmov(p, ".info"); // to have it right in the error message - slave_print_error(rli,my_errno, "Could not write to file '%s'", fname_buf); + slave_print_error(rli,my_errno, "Error in Create_file event: could not write to file '%s'", fname_buf); goto err; } end_io_cache(&file); @@ -2231,16 +2246,14 @@ int Create_file_log_event::exec_event(struct st_relay_log_info* rli) if ((fd = my_open(fname_buf, O_WRONLY|O_CREAT|O_BINARY|O_TRUNC, MYF(MY_WME))) < 0) { - slave_print_error(rli,my_errno, "Could not open file '%s'", fname_buf); + slave_print_error(rli,my_errno, "Error in Create_file event: could not open file '%s'", fname_buf); goto err; } if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP))) { - slave_print_error(rli,my_errno, "Write to '%s' failed", fname_buf); + slave_print_error(rli,my_errno, "Error in Create_file event: write to '%s' failed", fname_buf); goto err; } - if (mysql_bin_log.is_open()) - mysql_bin_log.write(this); error=0; // Everything is ok err: @@ -2259,8 +2272,6 @@ int Delete_file_log_event::exec_event(struct st_relay_log_info* rli) (void) my_delete(fname, MYF(MY_WME)); memcpy(p, ".info", 6); (void) my_delete(fname, MYF(MY_WME)); - if (mysql_bin_log.is_open()) - mysql_bin_log.write(this); return Log_event::exec_event(rli); } @@ -2274,16 +2285,14 @@ int Append_block_log_event::exec_event(struct st_relay_log_info* rli) memcpy(p, ".data", 6); if ((fd = my_open(fname, O_WRONLY|O_APPEND|O_BINARY, MYF(MY_WME))) < 0) { - slave_print_error(rli,my_errno, "Could not open file '%s'", fname); + slave_print_error(rli,my_errno, "Error in Append_block event: could not open file '%s'", fname); goto err; } if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP))) { - slave_print_error(rli,my_errno, "Write to '%s' failed", fname); + slave_print_error(rli,my_errno, "Error in Append_block event: write to '%s' failed", fname); goto err; } - if (mysql_bin_log.is_open()) - mysql_bin_log.write(this); error=0; err: @@ -2298,7 +2307,6 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli) char *p= slave_load_file_stem(fname, file_id, server_id); int fd; int error = 1; - ulong save_options; IO_CACHE file; Load_log_event* lev = 0; @@ -2307,7 +2315,7 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli) init_io_cache(&file, fd, IO_SIZE, READ_CACHE, (my_off_t)0, 0, MYF(MY_WME|MY_NABP))) { - slave_print_error(rli,my_errno, "Could not open file '%s'", fname); + slave_print_error(rli,my_errno, "Error in Exec_load event: could not open file '%s'", fname); goto err; } if (!(lev = (Load_log_event*)Log_event::read_log_event(&file, @@ -2315,21 +2323,16 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli) (bool)0)) || lev->get_type_code() != NEW_LOAD_EVENT) { - slave_print_error(rli,0, "File '%s' appears corrupted", fname); + slave_print_error(rli,0, "Error in Exec_load event: file '%s' appears corrupted", fname); goto err; } - /* - We want to disable binary logging in slave thread because we need the file - events to appear in the same order as they do on the master relative to - other events, so that we can preserve ascending order of log sequence - numbers - needed to handle failover . - */ - save_options = thd->options; - thd->options &= ~ (ulong) (OPTION_BIN_LOG); + lev->thd = thd; /* lev->exec_event should use rli only for errors - i.e. should not advance rli's position + i.e. should not advance rli's position. + lev->exec_event is the place where the table is loaded (it calls + mysql_load()). */ if (lev->exec_event(0,rli,1)) { @@ -2350,15 +2353,11 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli) tmp, fname); my_free(tmp,MYF(0)); } - thd->options= save_options; goto err; } - thd->options = save_options; (void) my_delete(fname, MYF(MY_WME)); memcpy(p, ".data", 6); (void) my_delete(fname, MYF(MY_WME)); - if (mysql_bin_log.is_open()) - mysql_bin_log.write(this); error = 0; err: diff --git a/sql/log_event.h b/sql/log_event.h index 1031b940528..227c0243b9c 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -687,9 +687,20 @@ public: char* block; uint block_len; uint file_id; - + /* + 'db' is filled when the event is created in mysql_load() (the event needs to + have a 'db' member to be well filtered by binlog-*-db rules). 'db' is not + written to the binlog (it's not used by Append_block_log_event::write()), so + it can't be read in the Append_block_log_event(const char* buf, int + event_len) constructor. + In other words, 'db' is used only for filtering by binlog-*-db rules. + Create_file_log_event is different: its 'db' (which is inherited from + Load_log_event) is written to the binlog and can be re-read. + */ + const char* db; + #ifndef MYSQL_CLIENT - Append_block_log_event(THD* thd, char* block_arg, + Append_block_log_event(THD* thd, const char* db_arg, char* block_arg, uint block_len_arg, bool using_trans); int exec_event(struct st_relay_log_info* rli); void pack_info(String* packet); @@ -703,6 +714,7 @@ public: int get_data_size() { return block_len + APPEND_BLOCK_HEADER_LEN ;} bool is_valid() { return block != 0; } int write_data(IO_CACHE* file); + const char* get_db() { return db; } }; @@ -710,9 +722,10 @@ class Delete_file_log_event: public Log_event { public: uint file_id; + const char* db; /* see comment in Append_block_log_event */ #ifndef MYSQL_CLIENT - Delete_file_log_event(THD* thd, bool using_trans); + Delete_file_log_event(THD* thd, const char* db_arg, bool using_trans); void pack_info(String* packet); int exec_event(struct st_relay_log_info* rli); #else @@ -725,15 +738,17 @@ public: int get_data_size() { return DELETE_FILE_HEADER_LEN ;} bool is_valid() { return file_id != 0; } int write_data(IO_CACHE* file); + const char* get_db() { return db; } }; class Execute_load_log_event: public Log_event { public: uint file_id; - + const char* db; /* see comment in Append_block_log_event */ + #ifndef MYSQL_CLIENT - Execute_load_log_event(THD* thd, bool using_trans); + Execute_load_log_event(THD* thd, const char* db_arg, bool using_trans); void pack_info(String* packet); int exec_event(struct st_relay_log_info* rli); #else @@ -746,6 +761,7 @@ public: int get_data_size() { return EXEC_LOAD_HEADER_LEN ;} bool is_valid() { return file_id != 0; } int write_data(IO_CACHE* file); + const char* get_db() { return db; } }; #ifdef MYSQL_CLIENT diff --git a/sql/slave.cc b/sql/slave.cc index 85a9bc0d49e..66a875b158f 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -57,7 +57,6 @@ typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; void skip_load_data_infile(NET* net); static int process_io_rotate(MASTER_INFO* mi, Rotate_log_event* rev); -static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev); static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli); static inline bool io_slave_killed(THD* thd,MASTER_INFO* mi); static inline bool sql_slave_killed(THD* thd,RELAY_LOG_INFO* rli); @@ -2730,102 +2729,6 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ } -static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) -{ - int error = 1; - ulong num_bytes; - bool cev_not_written; - THD* thd; - NET* net = &mi->mysql->net; - DBUG_ENTER("process_io_create_file"); - - if (unlikely(!cev->is_valid())) - DBUG_RETURN(1); - /* - TODO: fix to honor table rules, not only db rules - */ - if (!db_ok(cev->db, replicate_do_db, replicate_ignore_db)) - { - skip_load_data_infile(net); - DBUG_RETURN(0); - } - DBUG_ASSERT(cev->inited_from_old); - thd = mi->io_thd; - thd->file_id = cev->file_id = mi->file_id++; - thd->server_id = cev->server_id; - cev_not_written = 1; - - if (unlikely(net_request_file(net,cev->fname))) - { - sql_print_error("Slave I/O: failed requesting download of '%s'", - cev->fname); - goto err; - } - - /* - This dummy block is so we could instantiate Append_block_log_event - once and then modify it slightly instead of doing it multiple times - in the loop - */ - { - Append_block_log_event aev(thd,0,0,0); - - for (;;) - { - if (unlikely((num_bytes=my_net_read(net)) == packet_error)) - { - sql_print_error("Network read error downloading '%s' from master", - cev->fname); - goto err; - } - if (unlikely(!num_bytes)) /* eof */ - { - send_ok(net); /* 3.23 master wants it */ - Execute_load_log_event xev(thd,0); - xev.log_pos = mi->master_log_pos; - if (unlikely(mi->rli.relay_log.append(&xev))) - { - sql_print_error("Slave I/O: error writing Exec_load event to \ -relay log"); - goto err; - } - mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total); - break; - } - if (unlikely(cev_not_written)) - { - cev->block = (char*)net->read_pos; - cev->block_len = num_bytes; - cev->log_pos = mi->master_log_pos; - if (unlikely(mi->rli.relay_log.append(cev))) - { - sql_print_error("Slave I/O: error writing Create_file event to \ -relay log"); - goto err; - } - cev_not_written=0; - mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total); - } - else - { - aev.block = (char*)net->read_pos; - aev.block_len = num_bytes; - aev.log_pos = mi->master_log_pos; - if (unlikely(mi->rli.relay_log.append(&aev))) - { - sql_print_error("Slave I/O: error writing Append_block event to \ -relay log"); - goto err; - } - mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total) ; - } - } - } - error=0; -err: - DBUG_RETURN(error); -} - /* Start using a new binary log on the master @@ -2929,18 +2832,6 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, mi->ignore_stop_event=1; inc_pos= 0; break; - case CREATE_FILE_EVENT: - { - /* We come here when and only when tmp_buf != 0 */ - DBUG_ASSERT(tmp_buf); - int error = process_io_create_file(mi,(Create_file_log_event*)ev); - delete ev; - mi->master_log_pos += event_len; - DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); - pthread_mutex_unlock(&mi->data_lock); - my_free((char*)tmp_buf, MYF(0)); - DBUG_RETURN(error); - } default: mi->ignore_stop_event=0; inc_pos= event_len; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ee573672c35..593cfb82b1c 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -299,7 +299,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, which is nonsense. */ read_info.end_io_cache(); - Delete_file_log_event d(thd, log_delayed); + Delete_file_log_event d(thd, db, log_delayed); mysql_bin_log.write(&d); } } @@ -331,7 +331,7 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, read_info.end_io_cache(); // make sure last block gets logged if (lf_info.wrote_create_file) { - Execute_load_log_event e(thd, log_delayed); + Execute_load_log_event e(thd, db, log_delayed); mysql_bin_log.write(&e); } } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index cdd0bca4a0e..5a42614dff4 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -1216,7 +1216,7 @@ int log_loaded_block(IO_CACHE* file) lf_info->last_pos_in_file = file->pos_in_file; if (lf_info->wrote_create_file) { - Append_block_log_event a(lf_info->thd, buffer, block_len, + Append_block_log_event a(lf_info->thd, lf_info->db, buffer, block_len, lf_info->log_delayed); mysql_bin_log.write(&a); } From 78f54936a7f7668007a153891d4009d876741562 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 00:41:08 +0300 Subject: [PATCH 061/282] merge mysql-test/r/subselect.result: correct result after merging with fixed Item_in_optimiser::fix_left() mysql-test/t/subselect.test: error code changed --- mysql-test/r/subselect.result | 1 + mysql-test/t/subselect.test | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 510ce867100..cf02eda9aba 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -1350,4 +1350,5 @@ INSERT INTO t1 VALUES ('z','?'); select * from t1 where s1 > (select max(s2) from t1); ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>' select * from t1 where s1 > any (select max(s2) from t1); +ERROR HY000: Illegal mix of collations (latin1_german1_ci,IMPLICIT) and (latin1_swedish_ci,IMPLICIT) for operation '>' drop table t1; diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index 89f9c528237..457b64a5a11 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -907,8 +907,8 @@ drop table t1,t2; CREATE TABLE t1 (s1 CHAR(5) COLLATE latin1_german1_ci, s2 CHAR(5) COLLATE latin1_swedish_ci); INSERT INTO t1 VALUES ('z','?'); --- error 1265 +-- error 1266 select * from t1 where s1 > (select max(s2) from t1); --- error 1265 +-- error 1266 select * from t1 where s1 > any (select max(s2) from t1); drop table t1; From eb1fb90006fe4daa09d7d1ac5bb39a282a2427a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 00:23:39 +0200 Subject: [PATCH 062/282] Result updates after Dmitri's and my changes to logging with --log-slave-updates. Since my changes, rpl_log.test, whose result file depends on file_id, became non-repeatable, i.e. file_id on slave in SHOW BINLOG EVENTS changed depending on the order of tests (sometimes 1, sometimes 5). Which is logical: as now the slave does not copy Create_file and Exec_load from the relay log (i.e from the master's binlog) to the slave's binlog, but instead lets mysql_load() do the logging, the file_id is now the one whic was used on the slave. Before it was the one which was used on the master, and by chance the master was always restarted for this test because there's a -master.opt file, so file_id on the master is always 1. But now file_id is from the slave so we need to restart the slave. That's why I add an (empty) -slave.opt file. I could have used 'server_stop/start slave', but this would have required the manager, so most of the time mysql-test-run silently skip the test which makes it useless. And I want this test to be run ! mysql-test/r/rpl_loaddata.result: Orig_log_pos is like Pos since Dmitri's good change for BUG#1086 mysql-test/r/rpl_log.result: Orig_log_pos is like Pos now, because Exec_load events are not directly copied by the slave from the relay log to the slave's binary log (these events are written by mysql_load() now). mysql-test/t/rpl_log.test: A comment --- mysql-test/r/rpl_loaddata.result | 2 +- mysql-test/r/rpl_log.result | 2 +- mysql-test/t/rpl_log-slave.opt | 1 + mysql-test/t/rpl_log.test | 10 ++++++++++ 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 mysql-test/t/rpl_log-slave.opt diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index b42f78f01bd..e93f8487c32 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -22,7 +22,7 @@ day id category name 2003-04-22 2416 a bbbbb show binlog events from 898; Log_name Pos Event_type Server_id Orig_log_pos Info -slave-bin.001 898 Query 1 895 use test; insert into t3 select * from t2 +slave-bin.001 898 Query 1 898 use test; insert into t3 select * from t2 drop table t1; drop table t2; drop table t3; diff --git a/mysql-test/r/rpl_log.result b/mysql-test/r/rpl_log.result index fbec0542e4b..26e465f9c3b 100644 --- a/mysql-test/r/rpl_log.result +++ b/mysql-test/r/rpl_log.result @@ -84,7 +84,7 @@ slave-bin.001 200 Query 1 200 use test; insert into t1 values (NULL) slave-bin.001 263 Query 1 263 use test; drop table t1 slave-bin.001 311 Query 1 311 use test; create table t1 (word char(20) not null) slave-bin.001 386 Create_file 1 386 db=test;table=t1;file_id=1;block_len=581 -slave-bin.001 1065 Exec_load 1 1056 ;file_id=1 +slave-bin.001 1065 Exec_load 1 1065 ;file_id=1 slave-bin.001 1088 Query 1 1088 use test; drop table t1 slave-bin.001 1136 Query 1 1136 use test; create table t5 (a int) slave-bin.001 1194 Query 1 1194 use test; drop table t5 diff --git a/mysql-test/t/rpl_log-slave.opt b/mysql-test/t/rpl_log-slave.opt new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/mysql-test/t/rpl_log-slave.opt @@ -0,0 +1 @@ + diff --git a/mysql-test/t/rpl_log.test b/mysql-test/t/rpl_log.test index ad962b585a1..e01b3e4e09c 100644 --- a/mysql-test/t/rpl_log.test +++ b/mysql-test/t/rpl_log.test @@ -5,6 +5,16 @@ connection slave; slave stop; reset master; reset slave; +# We are going to read the slave's binlog which contains file_id (for some LOAD +# DATA INFILE); to make it repeatable (not influenced by other tests), we need +# to stop and start the slave, to be sure file_id will start from 1. +# This can be done with 'server_stop slave', but +# this would require the manager, so most of the time the test will be skipped +# :( +# To workaround this, I (Guilhem) add a (empty) rpl_log-slave.opt (because when +# mysql-test-run finds such a file it restarts the slave before doing the +# test). That's not very elegant but I could find no better way, sorry. + let $VERSION=`select version()`; connection master; From fd9b1775642e4da09697fd46a7bbb98d59b9843f Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 10:24:37 +0200 Subject: [PATCH 063/282] Yesterday I removed process_io_create_file; I shouldn't have. Let's say the lack of comments did not help me ;) Copying it back again and adding comments; now 3.23->4.0 replication of LOAD DATA INFILE works again. sql/slave.cc: Enabling again process_io_create_file --- sql/slave.cc | 121 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/sql/slave.cc b/sql/slave.cc index 9b5066f5804..32ed228e119 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -57,6 +57,7 @@ typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; void skip_load_data_infile(NET* net); static int process_io_rotate(MASTER_INFO* mi, Rotate_log_event* rev); +static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev); static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli); static inline bool io_slave_killed(THD* thd,MASTER_INFO* mi); static inline bool sql_slave_killed(THD* thd,RELAY_LOG_INFO* rli); @@ -2728,6 +2729,102 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ } +static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) +{ + int error = 1; + ulong num_bytes; + bool cev_not_written; + THD* thd; + NET* net = &mi->mysql->net; + DBUG_ENTER("process_io_create_file"); + + if (unlikely(!cev->is_valid())) + DBUG_RETURN(1); + /* + TODO: fix to honor table rules, not only db rules + */ + if (!db_ok(cev->db, replicate_do_db, replicate_ignore_db)) + { + skip_load_data_infile(net); + DBUG_RETURN(0); + } + DBUG_ASSERT(cev->inited_from_old); + thd = mi->io_thd; + thd->file_id = cev->file_id = mi->file_id++; + thd->server_id = cev->server_id; + cev_not_written = 1; + + if (unlikely(net_request_file(net,cev->fname))) + { + sql_print_error("Slave I/O: failed requesting download of '%s'", + cev->fname); + goto err; + } + + /* + This dummy block is so we could instantiate Append_block_log_event + once and then modify it slightly instead of doing it multiple times + in the loop + */ + { + Append_block_log_event aev(thd,0,0,0,0); + + for (;;) + { + if (unlikely((num_bytes=my_net_read(net)) == packet_error)) + { + sql_print_error("Network read error downloading '%s' from master", + cev->fname); + goto err; + } + if (unlikely(!num_bytes)) /* eof */ + { + send_ok(net); /* 3.23 master wants it */ + Execute_load_log_event xev(thd,0,0); + xev.log_pos = mi->master_log_pos; + if (unlikely(mi->rli.relay_log.append(&xev))) + { + sql_print_error("Slave I/O: error writing Exec_load event to \ +relay log"); + goto err; + } + mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total); + break; + } + if (unlikely(cev_not_written)) + { + cev->block = (char*)net->read_pos; + cev->block_len = num_bytes; + cev->log_pos = mi->master_log_pos; + if (unlikely(mi->rli.relay_log.append(cev))) + { + sql_print_error("Slave I/O: error writing Create_file event to \ +relay log"); + goto err; + } + cev_not_written=0; + mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total); + } + else + { + aev.block = (char*)net->read_pos; + aev.block_len = num_bytes; + aev.log_pos = mi->master_log_pos; + if (unlikely(mi->rli.relay_log.append(&aev))) + { + sql_print_error("Slave I/O: error writing Append_block event to \ +relay log"); + goto err; + } + mi->rli.relay_log.harvest_bytes_written(&mi->rli.log_space_total) ; + } + } + } + error=0; +err: + DBUG_RETURN(error); +} + /* Start using a new binary log on the master @@ -2803,6 +2900,12 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, tmp_buf[event_len]=0; // Create_file constructor wants null-term buffer buf = (const char*)tmp_buf; } + /* + This will transform LOAD_EVENT into CREATE_FILE_EVENT, ask the master to + send the loaded file, and write it to the relay log in the form of + Append_block/Exec_load (the SQL thread needs the data, as that thread is not + connected to the master). + */ Log_event *ev = Log_event::read_log_event(buf,event_len, &errmsg, 1 /*old format*/ ); if (unlikely(!ev)) @@ -2831,6 +2934,24 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, mi->ignore_stop_event=1; inc_pos= 0; break; + case CREATE_FILE_EVENT: + /* + Yes it's possible to have CREATE_FILE_EVENT here, even if we're in + queue_old_event() which is for 3.23 events which don't comprise + CREATE_FILE_EVENT. This is because read_log_event() above has just + transformed LOAD_EVENT into CREATE_FILE_EVENT. + */ + { + /* We come here when and only when tmp_buf != 0 */ + DBUG_ASSERT(tmp_buf); + int error = process_io_create_file(mi,(Create_file_log_event*)ev); + delete ev; + mi->master_log_pos += event_len; + DBUG_PRINT("info", ("master_log_pos: %d", (ulong) mi->master_log_pos)); + pthread_mutex_unlock(&mi->data_lock); + my_free((char*)tmp_buf, MYF(0)); + DBUG_RETURN(error); + } default: mi->ignore_stop_event=0; inc_pos= event_len; From c7f517b53f0074ca131e5747e176ebce18cc6171 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 10:44:17 +0200 Subject: [PATCH 064/282] sorted --- sql/set_var.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/set_var.cc b/sql/set_var.cc index 6dc36e312cb..8c0859fbca4 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -530,15 +530,15 @@ struct show_var_st init_vars[]= { {"log_error", (char*) log_error_file, SHOW_CHAR}, {"port", (char*) &mysql_port, SHOW_INT}, {"protocol_version", (char*) &protocol_version, SHOW_INT}, - {sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS}, - {sys_readonly.name, (char*) &sys_readonly, SHOW_SYS}, - {sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS}, - {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS}, #ifdef HAVE_QUERY_CACHE {sys_query_cache_limit.name,(char*) &sys_query_cache_limit, SHOW_SYS}, {sys_query_cache_size.name, (char*) &sys_query_cache_size, SHOW_SYS}, {sys_query_cache_type.name, (char*) &sys_query_cache_type, SHOW_SYS}, #endif /* HAVE_QUERY_CACHE */ + {sys_read_buff_size.name, (char*) &sys_read_buff_size, SHOW_SYS}, + {sys_readonly.name, (char*) &sys_readonly, SHOW_SYS}, + {sys_read_rnd_buff_size.name,(char*) &sys_read_rnd_buff_size, SHOW_SYS}, + {sys_rpl_recovery_rank.name,(char*) &sys_rpl_recovery_rank, SHOW_SYS}, {sys_server_id.name, (char*) &sys_server_id, SHOW_SYS}, {sys_slave_net_timeout.name,(char*) &sys_slave_net_timeout, SHOW_SYS}, {"skip_external_locking", (char*) &my_disable_locking, SHOW_MY_BOOL}, From 77a688766f32de69a82c6a072ab58ffdecadb58b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 12:15:22 +0200 Subject: [PATCH 065/282] - added missing option "--without-embedded" to be able to compile without the embedded server (it was missing in the previous push) --- Build-tools/Do-compile | 1 + 1 file changed, 1 insertion(+) diff --git a/Build-tools/Do-compile b/Build-tools/Do-compile index 6cf577162ed..e5783dbf515 100755 --- a/Build-tools/Do-compile +++ b/Build-tools/Do-compile @@ -51,6 +51,7 @@ GetOptions( "with-low-memory", "with-other-libc=s", "with-small-disk", + "without-embedded", ) || usage(); usage() if ($opt_help); From e103da7acc6f3563a2f7207e59c34b9d9ff64295 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 16:15:06 +0200 Subject: [PATCH 066/282] fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} checksum table command Com_xxx status variables updated sql/item_create.cc: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_func.cc: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_func.h: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_geofunc.h: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_strfunc.cc: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/item_strfunc.h: fixed a crash on COMPRESS() and other zlib-dependent functions when compiled w/o zlib moved them all from different places to item_strfunc.{h,cc} sql/mysql_priv.h: checksum table command sql/mysqld.cc: Com_xxx updated sql/sql_lex.h: checksum table command sql/sql_parse.cc: checksum table command sql/sql_table.cc: checksum table command sql/sql_yacc.yy: checksum table command --- sql/item_create.cc | 21 +++------------ sql/item_func.cc | 36 ++----------------------- sql/item_func.h | 21 --------------- sql/item_geofunc.h | 24 ----------------- sql/item_strfunc.cc | 55 ++++++++++++++++++++++++++++++------- sql/item_strfunc.h | 49 ++++++++++++++++++++++++++++++++- sql/mysql_priv.h | 1 + sql/mysqld.cc | 11 +++++--- sql/sql_lex.h | 4 +-- sql/sql_parse.cc | 8 ++++++ sql/sql_table.cc | 66 ++++++++++++++++++++++++++++++++++++++++++++- sql/sql_yacc.yy | 15 +++++++++-- 12 files changed, 197 insertions(+), 114 deletions(-) diff --git a/sql/item_create.cc b/sql/item_create.cc index e18d1cfa189..b0704931535 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -107,14 +107,6 @@ Item *create_func_cot(Item* a) new Item_func_tan(a)); } - -#ifdef HAVE_COMPRESS -Item *create_func_crc32(Item* a) -{ - return new Item_func_crc32(a); -} -#endif - Item *create_func_date_format(Item* a,Item *b) { return new Item_func_date_format(a,b,0); @@ -666,13 +658,10 @@ Item *create_func_point(Item *a, Item *b) return new Item_func_point(a, b); } -#if !defined(HAVE_COMPRESS) - -Item *create_func_compress (Item*a __attribute__((unused))){return 0;} -Item *create_func_uncompress (Item*a __attribute__((unused))){return 0;} -Item *create_func_uncompressed_length(Item*a __attribute__((unused))){return 0;} - -#else +Item *create_func_crc32(Item* a) +{ + return new Item_func_crc32(a); +} Item *create_func_compress(Item* a) { @@ -689,8 +678,6 @@ Item *create_func_uncompressed_length(Item* a) return new Item_func_uncompressed_length(a); } -#endif - Item *create_func_datediff(Item *a, Item *b) { return new Item_func_minus(new Item_func_to_days(a), diff --git a/sql/item_func.cc b/sql/item_func.cc index a7c5b35b8db..6350d3874a1 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -27,19 +27,16 @@ #include #include #include -#ifdef HAVE_COMPRESS -#include -#endif static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, const char *fname) { my_error(ER_CANT_AGGREGATE_2COLLATIONS,MYF(0), - c1.collation->name,c1.derivation_name(), + c1.collation->name,c1.derivation_name(), c2.collation->name,c2.derivation_name(), fname); } -static void my_coll_agg_error(DTCollation &c1, +static void my_coll_agg_error(DTCollation &c1, DTCollation &c2, DTCollation &c3, const char *fname) @@ -1039,35 +1036,6 @@ longlong Item_func_min_max::val_int() return value; } - -#ifdef HAVE_COMPRESS -longlong Item_func_crc32::val_int() -{ - String *res=args[0]->val_str(&value); - if (!res) - { - null_value=1; - return 0; /* purecov: inspected */ - } - null_value=0; - return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length()); -} - -longlong Item_func_uncompressed_length::val_int() -{ - String *res= args[0]->val_str(&value); - if (!res) - { - null_value=1; - return 0; /* purecov: inspected */ - } - null_value=0; - if (res->is_empty()) return 0; - return uint4korr(res->c_ptr()) & 0x3FFFFFFF; -} - -#endif /* HAVE_COMPRESS */ - longlong Item_func_length::val_int() { String *res=args[0]->val_str(&value); diff --git a/sql/item_func.h b/sql/item_func.h index 56ee0379cd5..b7e99bb37b7 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -553,27 +553,6 @@ public: }; -#ifdef HAVE_COMPRESS -class Item_func_crc32 :public Item_int_func -{ - String value; -public: - Item_func_crc32(Item *a) :Item_int_func(a) {} - longlong val_int(); - const char *func_name() const { return "crc32"; } - void fix_length_and_dec() { max_length=10; } -}; -class Item_func_uncompressed_length : public Item_int_func -{ - String value; -public: - Item_func_uncompressed_length(Item *a):Item_int_func(a){} - longlong val_int(); - const char *func_name() const{return "uncompressed_length";} - void fix_length_and_dec() { max_length=10; } -}; -#endif - class Item_func_length :public Item_int_func { String value; diff --git a/sql/item_geofunc.h b/sql/item_geofunc.h index d86914eb6c5..79e45cca26f 100644 --- a/sql/item_geofunc.h +++ b/sql/item_geofunc.h @@ -167,30 +167,6 @@ public: const char *func_name() const { return "multipoint"; } }; -#ifdef HAVE_COMPRESS - -class Item_func_compress: public Item_str_func -{ - String buffer; -public: - Item_func_compress(Item *a):Item_str_func(a){} - String *val_str(String *); - void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;} - const char *func_name() const{return "compress";} -}; - -class Item_func_uncompress: public Item_str_func -{ - String buffer; -public: - Item_func_uncompress(Item *a): Item_str_func(a){} - String *val_str(String *); - void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;} - const char *func_name() const{return "uncompress";} -}; - -#endif - /* Spatial relations */ diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index b92839e6c1e..7c6e6e0686c 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2548,9 +2548,47 @@ null: return 0; } +longlong Item_func_uncompressed_length::val_int() +{ + String *res= args[0]->val_str(&value); + if (!res) + { + null_value=1; + return 0; /* purecov: inspected */ + } + null_value=0; + if (res->is_empty()) return 0; + return uint4korr(res->c_ptr()) & 0x3FFFFFFF; +} + #ifdef HAVE_COMPRESS #include "zlib.h" +longlong Item_func_crc32::val_int() +{ + String *res=args[0]->val_str(&value); + if (!res) + { + null_value=1; + return 0; /* purecov: inspected */ + } + null_value=0; + return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length()); +} + +longlong Item_func_uncompressed_length::val_int() +{ + String *res= args[0]->val_str(&value); + if (!res) + { + null_value=1; + return 0; /* purecov: inspected */ + } + null_value=0; + if (res->is_empty()) return 0; + return uint4korr(res->c_ptr()) & 0x3FFFFFFF; +} + String *Item_func_compress::val_str(String *str) { String *res= args[0]->val_str(str); @@ -2575,7 +2613,7 @@ String *Item_func_compress::val_str(String *str) buffer.realloc((uint32)new_size + 4 + 1); Byte *body= ((Byte*)buffer.c_ptr()) + 4; - + if ((err= compress(body, &new_size, (const Bytef*)res->c_ptr(), res->length())) != Z_OK) { @@ -2597,7 +2635,7 @@ String *Item_func_compress::val_str(String *str) } buffer.length((uint32)new_size + 4); - + return &buffer; } @@ -2609,7 +2647,7 @@ String *Item_func_uncompress::val_str(String *str) ulong new_size= uint4korr(res->c_ptr()) & 0x3FFFFFFF; int err= Z_OK; uint code; - + if (new_size > MAX_BLOB_WIDTH) { push_warning_printf(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR, @@ -2618,21 +2656,20 @@ String *Item_func_uncompress::val_str(String *str) null_value= 0; return 0; } - + buffer.realloc((uint32)new_size); - - if ((err= uncompress((Byte*)buffer.c_ptr(), &new_size, + + if ((err= uncompress((Byte*)buffer.c_ptr(), &new_size, ((const Bytef*)res->c_ptr())+4,res->length())) == Z_OK) { buffer.length((uint32)new_size); return &buffer; } - - code= err==Z_BUF_ERROR ? ER_ZLIB_Z_BUF_ERROR : + + code= err==Z_BUF_ERROR ? ER_ZLIB_Z_BUF_ERROR : err==Z_MEM_ERROR ? ER_ZLIB_Z_MEM_ERROR : ER_ZLIB_Z_DATA_ERROR; push_warning(current_thd,MYSQL_ERROR::WARN_LEVEL_ERROR,code,ER(code)); null_value= 1; return 0; } - #endif diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index dfcc22b3443..d7547d69aed 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -623,9 +623,56 @@ public: Item_func_collation(Item *a) :Item_str_func(a) {} String *val_str(String *); const char *func_name() const { return "collation"; } - void fix_length_and_dec() + void fix_length_and_dec() { max_length=40; // should be enough collation.set(system_charset_info); }; }; + +#ifdef HAVE_COMPRESS +#define ZLIB_DEPENDED_FUNCTION ; +#else +#define ZLIB_DEPENDED_FUNCTION { null_value=1; return 0; } +#endif + +class Item_func_compress: public Item_str_func +{ + String buffer; +public: + Item_func_compress(Item *a):Item_str_func(a){} + void fix_length_and_dec(){max_length= (args[0]->max_length*120)/100+12;} + const char *func_name() const{return "compress";} + String *val_str(String *) ZLIB_DEPENDED_FUNCTION +}; + +class Item_func_uncompress: public Item_str_func +{ + String buffer; +public: + Item_func_uncompress(Item *a): Item_str_func(a){} + void fix_length_and_dec(){max_length= MAX_BLOB_WIDTH;} + const char *func_name() const{return "uncompress";} + String *val_str(String *) ZLIB_DEPENDED_FUNCTION +}; + +class Item_func_crc32 :public Item_int_func +{ + String value; +public: + Item_func_crc32(Item *a) :Item_int_func(a) {} + const char *func_name() const { return "crc32"; } + void fix_length_and_dec() { max_length=10; } + longlong val_int() ZLIB_DEPENDED_FUNCTION +}; + +class Item_func_uncompressed_length : public Item_int_func +{ + String value; +public: + Item_func_uncompressed_length(Item *a):Item_int_func(a){} + const char *func_name() const{return "uncompressed_length";} + void fix_length_and_dec() { max_length=10; } + longlong val_int(); +}; + diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 2c41d973f2e..9834d169ac4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -398,6 +398,7 @@ bool check_global_access(THD *thd, ulong want_access); int mysql_backup_table(THD* thd, TABLE_LIST* table_list); int mysql_restore_table(THD* thd, TABLE_LIST* table_list); +int mysql_checksum_table(THD* thd, TABLE_LIST* table_list); int mysql_check_table(THD* thd, TABLE_LIST* table_list, HA_CHECK_OPT* check_opt); int mysql_repair_table(THD* thd, TABLE_LIST* table_list, diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 8ddcbdc572f..fedaf32a45c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -4383,14 +4383,15 @@ struct show_var_st status_vars[]= { {"Bytes_received", (char*) &bytes_received, SHOW_LONG}, {"Bytes_sent", (char*) &bytes_sent, SHOW_LONG}, {"Com_admin_commands", (char*) &com_other, SHOW_LONG}, - {"Com_alter_table", (char*) (com_stat+(uint) SQLCOM_ALTER_TABLE),SHOW_LONG}, {"Com_alter_db", (char*) (com_stat+(uint) SQLCOM_ALTER_DB),SHOW_LONG}, + {"Com_alter_table", (char*) (com_stat+(uint) SQLCOM_ALTER_TABLE),SHOW_LONG}, {"Com_analyze", (char*) (com_stat+(uint) SQLCOM_ANALYZE),SHOW_LONG}, {"Com_backup_table", (char*) (com_stat+(uint) SQLCOM_BACKUP_TABLE),SHOW_LONG}, {"Com_begin", (char*) (com_stat+(uint) SQLCOM_BEGIN),SHOW_LONG}, {"Com_change_db", (char*) (com_stat+(uint) SQLCOM_CHANGE_DB),SHOW_LONG}, {"Com_change_master", (char*) (com_stat+(uint) SQLCOM_CHANGE_MASTER),SHOW_LONG}, {"Com_check", (char*) (com_stat+(uint) SQLCOM_CHECK),SHOW_LONG}, + {"Com_checksum", (char*) (com_stat+(uint) SQLCOM_CHECKSUM),SHOW_LONG}, {"Com_commit", (char*) (com_stat+(uint) SQLCOM_COMMIT),SHOW_LONG}, {"Com_create_db", (char*) (com_stat+(uint) SQLCOM_CREATE_DB),SHOW_LONG}, {"Com_create_function", (char*) (com_stat+(uint) SQLCOM_CREATE_FUNCTION),SHOW_LONG}, @@ -4403,6 +4404,7 @@ struct show_var_st status_vars[]= { {"Com_drop_function", (char*) (com_stat+(uint) SQLCOM_DROP_FUNCTION),SHOW_LONG}, {"Com_drop_index", (char*) (com_stat+(uint) SQLCOM_DROP_INDEX),SHOW_LONG}, {"Com_drop_table", (char*) (com_stat+(uint) SQLCOM_DROP_TABLE),SHOW_LONG}, + {"Com_drop_user", (char*) (com_stat+(uint) SQLCOM_DROP_USER),SHOW_LONG}, {"Com_flush", (char*) (com_stat+(uint) SQLCOM_FLUSH),SHOW_LONG}, {"Com_grant", (char*) (com_stat+(uint) SQLCOM_GRANT),SHOW_LONG}, {"Com_ha_close", (char*) (com_stat+(uint) SQLCOM_HA_CLOSE),SHOW_LONG}, @@ -4417,6 +4419,7 @@ struct show_var_st status_vars[]= { {"Com_load_master_table", (char*) (com_stat+(uint) SQLCOM_LOAD_MASTER_TABLE),SHOW_LONG}, {"Com_lock_tables", (char*) (com_stat+(uint) SQLCOM_LOCK_TABLES),SHOW_LONG}, {"Com_optimize", (char*) (com_stat+(uint) SQLCOM_OPTIMIZE),SHOW_LONG}, + {"Com_preload_keys", (char*) (com_stat+(uint) SQLCOM_PRELOAD_KEYS),SHOW_LONG}, {"Com_purge", (char*) (com_stat+(uint) SQLCOM_PURGE),SHOW_LONG}, {"Com_purge_before_date", (char*) (com_stat+(uint) SQLCOM_PURGE_BEFORE),SHOW_LONG}, {"Com_rename_table", (char*) (com_stat+(uint) SQLCOM_RENAME_TABLE),SHOW_LONG}, @@ -4426,12 +4429,14 @@ struct show_var_st status_vars[]= { {"Com_reset", (char*) (com_stat+(uint) SQLCOM_RESET),SHOW_LONG}, {"Com_restore_table", (char*) (com_stat+(uint) SQLCOM_RESTORE_TABLE),SHOW_LONG}, {"Com_revoke", (char*) (com_stat+(uint) SQLCOM_REVOKE),SHOW_LONG}, + {"Com_revoke_all", (char*) (com_stat+(uint) SQLCOM_REVOKE_ALL),SHOW_LONG}, {"Com_rollback", (char*) (com_stat+(uint) SQLCOM_ROLLBACK),SHOW_LONG}, {"Com_select", (char*) (com_stat+(uint) SQLCOM_SELECT),SHOW_LONG}, {"Com_set_option", (char*) (com_stat+(uint) SQLCOM_SET_OPTION),SHOW_LONG}, - {"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG}, {"Com_show_binlogs", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOGS),SHOW_LONG}, + {"Com_show_binlog_events", (char*) (com_stat+(uint) SQLCOM_SHOW_BINLOG_EVENTS),SHOW_LONG}, {"Com_show_charsets", (char*) (com_stat+(uint) SQLCOM_SHOW_CHARSETS),SHOW_LONG}, + {"Com_show_collations", (char*) (com_stat+(uint) SQLCOM_SHOW_COLLATIONS),SHOW_LONG}, {"Com_show_column_types", (char*) (com_stat+(uint) SQLCOM_SHOW_COLUMN_TYPES),SHOW_LONG}, {"Com_show_create_table", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE),SHOW_LONG}, {"Com_show_create_db", (char*) (com_stat+(uint) SQLCOM_SHOW_CREATE_DB),SHOW_LONG}, @@ -4439,6 +4444,7 @@ struct show_var_st status_vars[]= { {"Com_show_errors", (char*) (com_stat+(uint) SQLCOM_SHOW_ERRORS),SHOW_LONG}, {"Com_show_fields", (char*) (com_stat+(uint) SQLCOM_SHOW_FIELDS),SHOW_LONG}, {"Com_show_grants", (char*) (com_stat+(uint) SQLCOM_SHOW_GRANTS),SHOW_LONG}, + {"Com_show_innodb_status", (char*) (com_stat+(uint) SQLCOM_SHOW_INNODB_STATUS),SHOW_LONG}, {"Com_show_keys", (char*) (com_stat+(uint) SQLCOM_SHOW_KEYS),SHOW_LONG}, {"Com_show_logs", (char*) (com_stat+(uint) SQLCOM_SHOW_LOGS),SHOW_LONG}, {"Com_show_master_status", (char*) (com_stat+(uint) SQLCOM_SHOW_MASTER_STAT),SHOW_LONG}, @@ -4449,7 +4455,6 @@ struct show_var_st status_vars[]= { {"Com_show_slave_hosts", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_HOSTS),SHOW_LONG}, {"Com_show_slave_status", (char*) (com_stat+(uint) SQLCOM_SHOW_SLAVE_STAT),SHOW_LONG}, {"Com_show_status", (char*) (com_stat+(uint) SQLCOM_SHOW_STATUS),SHOW_LONG}, - {"Com_show_innodb_status", (char*) (com_stat+(uint) SQLCOM_SHOW_INNODB_STATUS),SHOW_LONG}, {"Com_show_tables", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLES),SHOW_LONG}, {"Com_show_table_types", (char*) (com_stat+(uint) SQLCOM_SHOW_TABLE_TYPES),SHOW_LONG}, {"Com_show_variables", (char*) (com_stat+(uint) SQLCOM_SHOW_VARIABLES),SHOW_LONG}, diff --git a/sql/sql_lex.h b/sql/sql_lex.h index abf1a9e4ab3..fb2f3181c23 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -60,7 +60,7 @@ enum enum_sql_command { SQLCOM_REPAIR, SQLCOM_REPLACE, SQLCOM_REPLACE_SELECT, SQLCOM_CREATE_FUNCTION, SQLCOM_DROP_FUNCTION, SQLCOM_REVOKE,SQLCOM_OPTIMIZE, SQLCOM_CHECK, SQLCOM_PRELOAD_KEYS, - SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE, + SQLCOM_FLUSH, SQLCOM_KILL, SQLCOM_ANALYZE, SQLCOM_ROLLBACK, SQLCOM_COMMIT, SQLCOM_SLAVE_START, SQLCOM_SLAVE_STOP, SQLCOM_BEGIN, SQLCOM_LOAD_MASTER_TABLE, SQLCOM_CHANGE_MASTER, SQLCOM_RENAME_TABLE, SQLCOM_BACKUP_TABLE, SQLCOM_RESTORE_TABLE, @@ -71,7 +71,7 @@ enum enum_sql_command { SQLCOM_SHOW_BINLOG_EVENTS, SQLCOM_SHOW_NEW_MASTER, SQLCOM_DO, SQLCOM_SHOW_WARNS, SQLCOM_EMPTY_QUERY, SQLCOM_SHOW_ERRORS, SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_TABLE_TYPES, SQLCOM_SHOW_PRIVILEGES, - SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, + SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM, /* This should be the last !!! */ SQLCOM_END diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ed68f487924..0e344756b18 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2264,6 +2264,14 @@ mysql_execute_command(THD *thd) break; } #endif + case SQLCOM_CHECKSUM: + { + if (check_db_used(thd,tables) || + check_table_access(thd, SELECT_ACL | EXTRA_ACL , tables)) + goto error; /* purecov: inspected */ + res = mysql_checksum_table(thd, tables); + break; + } case SQLCOM_REPAIR: { if (check_db_used(thd,tables) || diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 7cb8dfaae0d..d63a15c13a8 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2555,7 +2555,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, delete_count++; } else - found_count++; + found_count++; } end_read_record(&info); free_io_cache(from); @@ -2587,3 +2587,67 @@ copy_data_between_tables(TABLE *from,TABLE *to, *deleted=delete_count; DBUG_RETURN(error > 0 ? -1 : 0); } + +int mysql_checksum_table(THD* thd, TABLE_LIST* tables) +{ + TABLE_LIST *table; + List field_list; + Item *item; + Protocol *protocol= thd->protocol; + DBUG_ENTER("mysql_admin_table"); + + field_list.push_back(item = new Item_empty_string("Table", NAME_LEN*2)); + item->maybe_null= 1; + field_list.push_back(item=new Item_int("Checksum",(longlong) 1,21)); + item->maybe_null= 1; + if (protocol->send_fields(&field_list, 1)) + DBUG_RETURN(-1); + + for (table = tables; table; table = table->next) + { + char table_name[NAME_LEN*2+2]; + char* db = (table->db) ? table->db : thd->db; + bool fatal_error=0; + strxmov(table_name,db ? db : "",".",table->real_name,NullS); + + table->table = open_ltable(thd, table, TL_READ_NO_INSERT); +#ifdef EMBEDDED_LIBRARY + thd->net.last_errno= 0; // these errors shouldn't get client +#endif + + protocol->prepare_for_resend(); + protocol->store(table_name, system_charset_info); + + if (!table->table) + { + protocol->store_null(); + thd->net.last_error[0]=0; + } + else + { + table->table->pos_in_table_list= table; + + if (table->table->file->table_flags() & HA_HAS_CHECKSUM) + protocol->store((ulonglong)table->table->file->checksum()); + else + protocol->store_null(); +#ifdef EMBEDDED_LIBRARY + thd->net.last_errno= 0; // these errors shouldn't get client +#endif + + close_thread_tables(thd); + table->table=0; // For query cache + } + if (protocol->write()) + goto err; + } + + send_eof(thd); + DBUG_RETURN(0); + err: + close_thread_tables(thd); // Shouldn't be needed + if (table) + table->table=0; + DBUG_RETURN(-1); +} + diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c1b37bdba65..9be2b21debc 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -669,7 +669,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); insert_values update delete truncate rename show describe load alter optimize preload flush reset purge begin commit rollback slave master_def master_defs - repair restore backup analyze check start + repair restore backup analyze check start checksum field_list field_list_item field_spec kill column_def key_def preload_list preload_keys select_item_list select_item values_list no_braces @@ -727,6 +727,7 @@ verb_clause: | begin | change | check + | checksum | commit | create | delete @@ -1753,6 +1754,16 @@ backup: Lex->backup_dir = $6.str; }; +checksum: + CHECKSUM_SYM table_or_tables + { + LEX *lex=Lex; + lex->sql_command = SQLCOM_CHECKSUM; + } + table_list + {} + ; + repair: REPAIR opt_no_write_to_binlog table_or_tables { @@ -5152,7 +5163,7 @@ union_opt: ; optional_order_or_limit: - /* Empty */ {} + /* Empty */ {} | { THD *thd= YYTHD; From c1551b4c04a68699872d80b7e1b9e5a969e4ff72 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 18:30:43 +0200 Subject: [PATCH 067/282] use crc32() from bundled zlib if system zlib is unavailable sql/item_create.h: previous patch cleanup sql/item_strfunc.cc: previous patch cleanup sql/item_strfunc.h: previous patch cleanup sql/lex.h: previous patch cleanup --- include/my_sys.h | 3 ++- mysys/Makefile.am | 2 +- mysys/my_crc32.c | 36 ++++++++++++++++++++++++++++++++++++ sql/item_create.h | 2 -- sql/item_strfunc.cc | 19 +++---------------- sql/item_strfunc.h | 40 ++++++++++++++++++++-------------------- sql/lex.h | 2 -- 7 files changed, 62 insertions(+), 42 deletions(-) create mode 100644 mysys/my_crc32.c diff --git a/include/my_sys.h b/include/my_sys.h index 6721d77a8af..a6a4d46e227 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -753,8 +753,9 @@ extern my_bool my_uncompress(byte *, ulong *, ulong *); extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); extern uint my_bit_log2(ulong value); -uint my_count_bits(ulonglong v); +extern uint my_count_bits(ulonglong v); extern void my_sleep(ulong m_seconds); +extern ulong crc32(ulong crc, const uchar *buf, uint len); #ifdef __WIN__ extern my_bool have_tcpip; /* Is set if tcpip is used */ diff --git a/mysys/Makefile.am b/mysys/Makefile.am index 5b1c859cb2a..9e563755ebd 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -29,7 +29,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c\ mf_path.c mf_loadpath.c\ my_open.c my_create.c my_dup.c my_seek.c my_read.c \ my_pread.c my_write.c \ - mf_keycache.c \ + mf_keycache.c my_crc32.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ my_malloc.c my_realloc.c my_once.c mulalloc.c \ diff --git a/mysys/my_crc32.c b/mysys/my_crc32.c new file mode 100644 index 00000000000..5514b01ede2 --- /dev/null +++ b/mysys/my_crc32.c @@ -0,0 +1,36 @@ +/* Copyright (C) 2003 MySQL 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 */ + +#include "mysys_priv.h" + +#ifndef HAVE_COMPRESS + +/* minimal set of defines for using crc32() from zlib codebase */ +#define _ZLIB_H +#define ZEXPORT +#define Z_NULL 0 +#define OF(args) args +#undef DYNAMIC_CRC_TABLE +typedef uchar Byte; +typedef uchar Bytef; +typedef uint uInt; +typedef ulong uLong; +typedef ulong uLongf; + +#include "../zlib/crc32.c" + +#endif + diff --git a/sql/item_create.h b/sql/item_create.h index 1326077b096..e80272e21a5 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -33,9 +33,7 @@ Item *create_func_connection_id(void); Item *create_func_conv(Item* a, Item *b, Item *c); Item *create_func_cos(Item* a); Item *create_func_cot(Item* a); -#ifdef HAVE_COMPRESS Item *create_func_crc32(Item* a); -#endif Item *create_func_date_format(Item* a,Item *b); Item *create_func_dayname(Item* a); Item *create_func_dayofmonth(Item* a); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 7c6e6e0686c..cb24fb0f027 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2561,9 +2561,6 @@ longlong Item_func_uncompressed_length::val_int() return uint4korr(res->c_ptr()) & 0x3FFFFFFF; } -#ifdef HAVE_COMPRESS -#include "zlib.h" - longlong Item_func_crc32::val_int() { String *res=args[0]->val_str(&value); @@ -2573,21 +2570,11 @@ longlong Item_func_crc32::val_int() return 0; /* purecov: inspected */ } null_value=0; - return (longlong) crc32(0L, (Bytef*)res->ptr(), res->length()); + return (longlong) crc32(0L, (uchar*)res->ptr(), res->length()); } -longlong Item_func_uncompressed_length::val_int() -{ - String *res= args[0]->val_str(&value); - if (!res) - { - null_value=1; - return 0; /* purecov: inspected */ - } - null_value=0; - if (res->is_empty()) return 0; - return uint4korr(res->c_ptr()) & 0x3FFFFFFF; -} +#ifdef HAVE_COMPRESS +#include "zlib.h" String *Item_func_compress::val_str(String *str) { diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index d7547d69aed..a8725febe62 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -630,6 +630,26 @@ public: }; }; +class Item_func_crc32 :public Item_int_func +{ + String value; +public: + Item_func_crc32(Item *a) :Item_int_func(a) {} + const char *func_name() const { return "crc32"; } + void fix_length_and_dec() { max_length=10; } + longlong val_int(); +}; + +class Item_func_uncompressed_length : public Item_int_func +{ + String value; +public: + Item_func_uncompressed_length(Item *a):Item_int_func(a){} + const char *func_name() const{return "uncompressed_length";} + void fix_length_and_dec() { max_length=10; } + longlong val_int(); +}; + #ifdef HAVE_COMPRESS #define ZLIB_DEPENDED_FUNCTION ; #else @@ -656,23 +676,3 @@ public: String *val_str(String *) ZLIB_DEPENDED_FUNCTION }; -class Item_func_crc32 :public Item_int_func -{ - String value; -public: - Item_func_crc32(Item *a) :Item_int_func(a) {} - const char *func_name() const { return "crc32"; } - void fix_length_and_dec() { max_length=10; } - longlong val_int() ZLIB_DEPENDED_FUNCTION -}; - -class Item_func_uncompressed_length : public Item_int_func -{ - String value; -public: - Item_func_uncompressed_length(Item *a):Item_int_func(a){} - const char *func_name() const{return "uncompressed_length";} - void fix_length_and_dec() { max_length=10; } - longlong val_int(); -}; - diff --git a/sql/lex.h b/sql/lex.h index 35c4d990b32..7ac61c73ad8 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -472,9 +472,7 @@ static SYMBOL sql_functions[] = { { "COUNT", SYM(COUNT_SYM),0,0}, { "COS", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cos)}, { "COT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_cot)}, -#ifdef HAVE_COMPRESS { "CRC32", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_crc32)}, -#endif { "CROSSES", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_crosses)}, { "CURDATE", SYM(CURDATE),0,0}, { "CURTIME", SYM(CURTIME),0,0}, From c7614597ab5b7145c9ea816f09374f46747ea125 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 20:13:26 +0200 Subject: [PATCH 068/282] crash BUG#1116 fixed --- strings/ctype-tis620.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 885d4406cd6..edadadf3a43 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -49,7 +49,7 @@ #include "m_ctype.h" #include "t_ctype.h" -static uchar* thai2sortable(const uchar *tstr,uint len); +static uchar* thai2sortable(const uchar *tstr,int len); #define BUFFER_MULTIPLY 4 #define buffsize(s) (BUFFER_MULTIPLY * (strlen(s) + 1)) @@ -456,7 +456,7 @@ uchar NEAR sort_order_tis620[]= /* NOTE: isn't it faster to alloc buffer in calling function? */ -static uchar* thai2sortable(const uchar * tstr,uint len) +static uchar* thai2sortable(const uchar * tstr,int len) { /* We use only 3 levels (neglect capitalization). */ @@ -467,16 +467,16 @@ static uchar* thai2sortable(const uchar * tstr,uint len) uint bufSize; uint RightSize; - len= (uint) strnlen((char*) tstr,len); + len= (int) strnlen((char*) tstr,len); bufSize= (uint) buffsize((char*) tstr); RightSize= sizeof(uchar) * (len + 1); - if (!(outBuf= pLeft1= pRight1= + if (!(outBuf= pLeft1= pRight1= (uchar *)malloc(sizeof(uchar) * bufSize + RightSize*2))) return (uchar*) tstr; pLeft2= pRight2= pRight1 + sizeof(uchar) * bufSize; pLeft3= pRight3= pRight2 + RightSize; - while (--len) + while (--len > 0) { int *t_ctype0= t_ctype[p[0]]; if (isldvowel(*p) && isconsnt(p[1])) @@ -567,8 +567,8 @@ int my_strcoll_tis620(const uchar * s1, const uchar * s2) { uchar *tc1, *tc2; int i; - tc1= thai2sortable(s1, (uint) strlen((char*)s1)); - tc2= thai2sortable(s2, (uint) strlen((char*)s2)); + tc1= thai2sortable(s1, (int) strlen((char*)s1)); + tc2= thai2sortable(s2, (int) strlen((char*)s2)); i= strcmp((char*)tc1, (char*)tc2); free(tc1); free(tc2); From 87b1e4cec69a26cc2009663750642d044938e1df Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 20:21:07 +0200 Subject: [PATCH 069/282] fix for SHOW CREATE TABLE to report corerct second field's length --- sql/item.cc | 5 ++++ sql/sql_show.cc | 70 ++++++++++++++++++++++++------------------------- 2 files changed, 39 insertions(+), 36 deletions(-) diff --git a/sql/item.cc b/sql/item.cc index a2d9f0b2575..a09aa9962bc 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -355,6 +355,11 @@ void Item_string::make_field(Send_field *tmp_field) init_make_field(tmp_field,FIELD_TYPE_STRING); } +void Item_empty_string::make_field(Send_field *tmp_field) +{ + init_make_field(tmp_field,FIELD_TYPE_VAR_STRING); +} + void Item_datetime::make_field(Send_field *tmp_field) { init_make_field(tmp_field,FIELD_TYPE_DATETIME); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index dc81510051b..6acdb1cc72b 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -564,49 +564,47 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) DBUG_RETURN(1); } + String packet; + packet.length(0); + net_store_data(&packet, table->table_name); + /* + A hack - we need to reserve some space for the length before + we know what it is - let's assume that the length of create table + statement will fit into 3 bytes ( 16 MB max :-) ) + */ + ulong store_len_offset = packet.length(); + packet.length(store_len_offset + 4); + if (store_create_info(thd, table, &packet)) + DBUG_RETURN(-1); + ulong create_len = packet.length() - store_len_offset - 4; + if (create_len > 0x00ffffff) // better readable in HEX ... + { + /* + Just in case somebody manages to create a table + with *that* much stuff in the definition + */ + DBUG_RETURN(1); + } + + /* + Now we have to store the length in three bytes, even if it would fit + into fewer bytes, so we cannot use net_store_data() anymore, + and do it ourselves + */ + char* p = (char*)packet.ptr() + store_len_offset; + *p++ = (char) 253; // The client the length is stored using 3-bytes + int3store(p, create_len); + List field_list; field_list.push_back(new Item_empty_string("Table",NAME_LEN)); - field_list.push_back(new Item_empty_string("Create Table",1024)); + field_list.push_back(new Item_empty_string("Create Table",packet.length())); if (send_fields(thd,field_list,1)) DBUG_RETURN(1); - String *packet = &thd->packet; - { - packet->length(0); - net_store_data(packet, table->table_name); - /* - A hack - we need to reserve some space for the length before - we know what it is - let's assume that the length of create table - statement will fit into 3 bytes ( 16 MB max :-) ) - */ - ulong store_len_offset = packet->length(); - packet->length(store_len_offset + 4); - if (store_create_info(thd, table, packet)) - DBUG_RETURN(-1); - ulong create_len = packet->length() - store_len_offset - 4; - if (create_len > 0x00ffffff) // better readable in HEX ... - { - /* - Just in case somebody manages to create a table - with *that* much stuff in the definition - */ - DBUG_RETURN(1); - } + if (my_net_write(&thd->net, (char*)packet.ptr(), packet.length())) + DBUG_RETURN(1); - /* - Now we have to store the length in three bytes, even if it would fit - into fewer bytes, so we cannot use net_store_data() anymore, - and do it ourselves - */ - char* p = (char*)packet->ptr() + store_len_offset; - *p++ = (char) 253; // The client the length is stored using 3-bytes - int3store(p, create_len); - - // now we are in business :-) - if (my_net_write(&thd->net, (char*)packet->ptr(), packet->length())) - DBUG_RETURN(1); - } send_eof(&thd->net); DBUG_RETURN(0); } From b8de463ea17289747fe940ba048707498336f951 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 21 Aug 2003 21:14:02 +0200 Subject: [PATCH 070/282] Bug #1064: SHOW CREATE TABLE: avoid allocations for simple tables, old client compatibility sql/item.h: fixups sql/sql_show.cc: avoid allocations for simple tables old client compatibility --- sql/item.h | 1 + sql/sql_show.cc | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/item.h b/sql/item.h index 3cf5a17805c..d9d125b8bd4 100644 --- a/sql/item.h +++ b/sql/item.h @@ -275,6 +275,7 @@ class Item_empty_string :public Item_string public: Item_empty_string(const char *header,uint length) :Item_string("",0) { name=(char*) header; max_length=length;} + void make_field(Send_field *field); }; class Item_varbinary :public Item diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6acdb1cc72b..f2d6dd8e058 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -564,7 +564,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) DBUG_RETURN(1); } - String packet; + char buff[1024]; + String packet(buff,sizeof(buff)); packet.length(0); net_store_data(&packet, table->table_name); /* @@ -597,7 +598,8 @@ mysqld_show_create(THD *thd, TABLE_LIST *table_list) List field_list; field_list.push_back(new Item_empty_string("Table",NAME_LEN)); - field_list.push_back(new Item_empty_string("Create Table",packet.length())); + field_list.push_back(new Item_empty_string("Create Table", + max(packet.length(),1024))); // 1024 is for not to confuse old clients if (send_fields(thd,field_list,1)) DBUG_RETURN(1); From 64393d7e24fe90f5badf3f25f25cc5a24f34b70e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Aug 2003 04:07:40 +0300 Subject: [PATCH 071/282] Move test that uses many tables (in query_cache.test) to separate test so that we can get it 'skipped' instead of 'failed' on system where we can't open many files. client/mysqltest.c: Fix that LET can be used with queries that return multiple columns libmysql/errmsg.c: Extend socket name to 100 characters in error messages libmysql/libmysql.c: Reset some variables to make ensure that we can call mysql_server_init()/mysql_server_end() many times mysql-test/mysql-test-run.sh: Set open-files-limit to 1024 mysql-test/r/loaddata.result: Add test case for LOAD DATA bug report (was not a bug) mysql-test/r/query_cache.result: Move test with many tables to separate test mysql-test/r/select_safe.result: Make test repeatable mysql-test/t/loaddata.test: Add test case for LOAD DATA bug report (was not a bug) mysql-test/t/query_cache.test: Move test with many tables to separate test mysql-test/t/select_safe.test: Make test repeatable sql/field.cc: Portability fix for gcc 3.3 sql/mysqld.cc: Store in open_files_limit the true number of files we can open (if system supports it) sql/sql_load.cc: Safety fix --- client/mysqltest.c | 29 ++++++++++++++++---- libmysql/errmsg.c | 36 ++++++++++++------------ libmysql/libmysql.c | 7 +++++ mysql-test/include/check_var_limit.inc | 9 ++++++ mysql-test/mysql-test-run.sh | 8 +++++- mysql-test/r/check_var_limit.require | 2 ++ mysql-test/r/loaddata.result | 10 +++++++ mysql-test/r/query_cache.result | 20 +------------- mysql-test/r/query_cache_merge.result | 20 ++++++++++++++ mysql-test/r/select_safe.result | 4 +-- mysql-test/std_data/loaddata2.dat | 5 ++++ mysql-test/t/loaddata.test | 7 +++-- mysql-test/t/query_cache.test | 24 +--------------- mysql-test/t/query_cache_merge.test | 38 ++++++++++++++++++++++++++ mysql-test/t/select_safe.test | 4 +-- sql/field.cc | 9 +++++- sql/mysqld.cc | 16 +++++++++++ sql/sql_load.cc | 8 ++++-- 18 files changed, 180 insertions(+), 76 deletions(-) create mode 100644 mysql-test/include/check_var_limit.inc create mode 100644 mysql-test/r/check_var_limit.require create mode 100644 mysql-test/r/query_cache_merge.result create mode 100644 mysql-test/std_data/loaddata2.dat create mode 100644 mysql-test/t/query_cache_merge.test diff --git a/client/mysqltest.c b/client/mysqltest.c index f5afa0fa0df..7a5712cc597 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -42,7 +42,7 @@ **********************************************************************/ -#define MTEST_VERSION "1.27" +#define MTEST_VERSION "1.28" #include #include @@ -845,7 +845,28 @@ int var_query_set(VAR* v, const char* p, const char** p_end) } if ((row = mysql_fetch_row(res)) && row[0]) - eval_expr(v, row[0], 0); + { + /* + Concatenate all row results with tab in between to allow us to work + with results from many columns (for example from SHOW VARIABLES) + */ + DYNAMIC_STRING result; + uint i; + ulong *lengths; + char *end; + + init_dynamic_string(&result, "", 16384, 65536); + lengths= mysql_fetch_lengths(res); + for (i=0; i < mysql_num_fields(res); i++) + { + if (row[0]) + dynstr_append_mem(&result, row[i], lengths[i]); + dynstr_append_mem(&result, "\t", 1); + } + end= result.str + result.length-1; + eval_expr(v, result.str, (const char**) &end); + dynstr_free(&result); + } else eval_expr(v, "", 0); @@ -902,8 +923,6 @@ int eval_expr(VAR* v, const char* p, const char** p_end) return 0; } - if (p_end) - *p_end = 0; die("Invalid expr: %s", p); return 1; } @@ -1197,7 +1216,7 @@ static char *get_string(char **to_ptr, char **from_ptr, VAR *var=var_get(start, &end, 0, 1); if (var && to == (char*) end+1) { - DBUG_PRINT("info",("var: %s -> %s", start, var->str_val)); + DBUG_PRINT("info",("var: '%s' -> '%s'", start, var->str_val)); DBUG_RETURN(var->str_val); /* return found variable value */ } } diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 375ca7329c0..7accbf8f1d2 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -26,24 +26,24 @@ const char *client_errors[]= { "Unbekannter MySQL Fehler", "Kann UNIX-Socket nicht anlegen (%d)", - "Keine Verbindung zu lokalem MySQL Server, socket: '%-.64s' (%d)", - "Keine Verbindung zu MySQL Server auf %-.64s (%d)", + "Keine Verbindung zu lokalem MySQL Server, socket: '%-.100s' (%d)", + "Keine Verbindung zu MySQL Server auf %-.100s (%d)", "Kann TCP/IP-Socket nicht anlegen (%d)", - "Unbekannter MySQL Server Host (%-.64s) (%d)", + "Unbekannter MySQL Server Host (%-.100s) (%d)", "MySQL Server nicht vorhanden", "Protokolle ungleich. Server Version = % d Client Version = %d", "MySQL client got out of memory", "Wrong host info", "Localhost via UNIX socket", - "%-.64s via TCP/IP", + "%-.100s via TCP/IP", "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; You can't run this command now", - "Verbindung ueber Named Pipe; Host: %-.64s", + "Verbindung ueber Named Pipe; Host: %-.100s", "Kann nicht auf Named Pipe warten. Host: %-.64s pipe: %-.32s (%lu)", "Kann Named Pipe nicht oeffnen. Host: %-.64s pipe: %-.32s (%lu)", "Kann den Status der Named Pipe nicht setzen. Host: %-.64s pipe: %-.32s (%lu)", - "Can't initialize character set %-.64s (path: %-.64s)", + "Can't initialize character set %-.32s (path: %-.100s)", "Got packet bigger than 'max_allowed_packet'", "Embedded server", "Error on SHOW SLAVE STATUS:", @@ -61,24 +61,24 @@ const char *client_errors[]= { "Erro desconhecido do MySQL", "Não pode criar 'UNIX socket' (%d)", - "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.64s' (%d)", - "Não pode se conectar ao servidor MySQL em '%-.64s' (%d)", + "Não pode se conectar ao servidor MySQL local através do 'socket' '%-.100s' (%d)", + "Não pode se conectar ao servidor MySQL em '%-.100s' (%d)", "Não pode criar 'socket TCP/IP' (%d)", - "'Host' servidor MySQL '%-.64s' (%d) desconhecido", + "'Host' servidor MySQL '%-.100s' (%d) desconhecido", "Servidor MySQL desapareceu", "Incompatibilidade de protocolos. Versão do Servidor: %d - Versão do Cliente: %d", "Cliente do MySQL com falta de memória", "Informação inválida de 'host'", "Localhost via 'UNIX socket'", - "%-.64s via 'TCP/IP'", + "%-.100s via 'TCP/IP'", "Erro na negociação de acesso ao servidor", "Conexão perdida com servidor MySQL durante 'query'", "Comandos fora de sincronismo. Você não pode executar este comando agora", - "%-.64s via 'named pipe'", + "%-.100s via 'named pipe'", "Não pode esperar pelo 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "Não pode abrir 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", "Não pode estabelecer o estado do 'named pipe' para o 'host' %-.64s - 'pipe' %-.32s (%lu)", - "Não pode inicializar conjunto de caracteres %-.64s (caminho %-.64s)", + "Não pode inicializar conjunto de caracteres %-.32s (caminho %-.100s)", "Obteve pacote maior do que 'max_allowed_packet'", "Embedded server" "Error on SHOW SLAVE STATUS:", @@ -94,24 +94,24 @@ const char *client_errors[]= { "Unknown MySQL error", "Can't create UNIX socket (%d)", - "Can't connect to local MySQL server through socket '%-.64s' (%d)", - "Can't connect to MySQL server on '%-.64s' (%d)", + "Can't connect to local MySQL server through socket '%-.100s' (%d)", + "Can't connect to MySQL server on '%-.100s' (%d)", "Can't create TCP/IP socket (%d)", - "Unknown MySQL Server Host '%-.64s' (%d)", + "Unknown MySQL Server Host '%-.100s' (%d)", "MySQL server has gone away", "Protocol mismatch. Server Version = %d Client Version = %d", "MySQL client run out of memory", "Wrong host info", "Localhost via UNIX socket", - "%-.64s via TCP/IP", + "%-.100s via TCP/IP", "Error in server handshake", "Lost connection to MySQL server during query", "Commands out of sync; You can't run this command now", - "%-.64s via named pipe", + "%-.100s via named pipe", "Can't wait for named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't open named pipe to host: %-.64s pipe: %-.32s (%lu)", "Can't set state of named pipe to host: %-.64s pipe: %-.32s (%lu)", - "Can't initialize character set %-.64s (path: %-.64s)", + "Can't initialize character set %-.32s (path: %-.100s)", "Got packet bigger than 'max_allowed_packet'", "Embedded server", "Error on SHOW SLAVE STATUS:", diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index aa169335dfb..9e32e60f7da 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -110,9 +110,16 @@ void STDCALL mysql_server_end() { /* If library called my_init(), free memory allocated by it */ if (!org_my_init_done) + { my_end(0); +#ifndef THREAD + /* Remove TRACING, if enabled by mysql_debug() */ + DBUG_POP(); +#endif + } else mysql_thread_end(); + mysql_client_init= org_my_init_done= 0; } my_bool STDCALL mysql_thread_init() diff --git a/mysql-test/include/check_var_limit.inc b/mysql-test/include/check_var_limit.inc new file mode 100644 index 00000000000..5f26e2b99a9 --- /dev/null +++ b/mysql-test/include/check_var_limit.inc @@ -0,0 +1,9 @@ +# +# Check that second part of $LIMIT is between $MIN_LIMIT and $MAX_LIMIT +# This is useful to check that a variable from SHOW_VARIABLES is within +# certain limits. Check query_cache_merge.test for an example of using this. +# +-- require r/check_var_limit.require +disable_query_log; +eval select SUBSTRING_INDEX($LIMIT, "\t", 2) BETWEEN $MIN_LIMIT AND $MAX_LIMIT as "limit"; +enable_query_log; diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index bf5546483d3..1d1293f81d2 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -16,6 +16,9 @@ USE_MANAGER=0 MY_TZ=GMT-3 TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work +# For query_cache test +ulimit -n 1024 + #++ # Program Definitions #-- @@ -829,7 +832,6 @@ start_master() /bin/sh $master_init_script fi cd $BASEDIR # for gcov - #start master if [ -z "$DO_BENCH" ] then master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin \ @@ -848,6 +850,7 @@ start_master() --tmpdir=$MYSQL_TMP_DIR \ --language=$LANGUAGE \ --innodb_data_file_path=ibdata1:50M \ + --open-files-limit=1024 \ $MASTER_40_ARGS \ $SMALL_SERVER \ $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT" @@ -1363,6 +1366,9 @@ fi $ECHO "Starting Tests" +# +# This can probably be deleted +# if [ "$DO_BENCH" = 1 ] then BENCHDIR=$BASEDIR/sql-bench/ diff --git a/mysql-test/r/check_var_limit.require b/mysql-test/r/check_var_limit.require new file mode 100644 index 00000000000..01a59782180 --- /dev/null +++ b/mysql-test/r/check_var_limit.require @@ -0,0 +1,2 @@ +limit +1 diff --git a/mysql-test/r/loaddata.result b/mysql-test/r/loaddata.result index 59153f3353a..0b7925de1c5 100644 --- a/mysql-test/r/loaddata.result +++ b/mysql-test/r/loaddata.result @@ -16,3 +16,13 @@ NULL NULL 0000-00-00 0000-00-00 NULL 0000-00-00 0000-00-00 0000-00-00 NULL 2003-03-03 2003-03-03 NULL drop table t1; +create table t1 (a text, b text); +load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +select concat('|',a,'|'), concat('|',b,'|') from t1; +concat('|',a,'|') concat('|',b,'|') +|Field A| |Field B| +|Field 1| |Field 2' +Field 3,'Field 4| +|Field 5' ,'Field 6| NULL +|Field 6| | 'Field 7'| +drop table t1; diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result index 48df3b4b563..0b86c79afbf 100644 --- a/mysql-test/r/query_cache.result +++ b/mysql-test/r/query_cache.result @@ -2,7 +2,7 @@ flush query cache; flush query cache; reset query cache; flush status; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00,mysqltest.t1; +drop table if exists t1,t2,t3; drop database if exists mysqltest; create table t1 (a int not null); insert into t1 values (1),(2),(3); @@ -640,21 +640,3 @@ Variable_name Value Qcache_queries_in_cache 2 SET OPTION SQL_SELECT_LIMIT=DEFAULT; drop table t1; -flush status; -select count(*) from t00; -count(*) -514 -select count(*) from t00; -count(*) -514 -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 1 -show status like "Qcache_hits"; -Variable_name Value -Qcache_hits 1 -delete from t256; -show status like "Qcache_queries_in_cache"; -Variable_name Value -Qcache_queries_in_cache 0 -drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; diff --git a/mysql-test/r/query_cache_merge.result b/mysql-test/r/query_cache_merge.result new file mode 100644 index 00000000000..c6df4266de2 --- /dev/null +++ b/mysql-test/r/query_cache_merge.result @@ -0,0 +1,20 @@ +SET @@global.query_cache_size=1355776; +flush status; +select count(*) from t00; +count(*) +514 +select count(*) from t00; +count(*) +514 +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 1 +show status like "Qcache_hits"; +Variable_name Value +Qcache_hits 1 +delete from t256; +show status like "Qcache_queries_in_cache"; +Variable_name Value +Qcache_queries_in_cache 0 +drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; +SET @@global.query_cache_size=0; diff --git a/mysql-test/r/select_safe.result b/mysql-test/r/select_safe.result index ca5c03bdb50..c4e5984d360 100644 --- a/mysql-test/r/select_safe.result +++ b/mysql-test/r/select_safe.result @@ -67,12 +67,12 @@ analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status OK insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"); -explain select * from t1,t1 as t2 where t1.b=t2.b; +explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; table type possible_keys key key_len ref rows Extra t1 ALL b NULL NULL NULL 21 t2 ALL b NULL NULL NULL 16 Using where set MAX_SEEKS_FOR_KEY=1; -explain select * from t1,t1 as t2 where t1.b=t2.b; +explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; table type possible_keys key key_len ref rows Extra t1 ALL b NULL NULL NULL 21 t2 ref b b 21 t1.b 6 Using where diff --git a/mysql-test/std_data/loaddata2.dat b/mysql-test/std_data/loaddata2.dat new file mode 100644 index 00000000000..6e9d6745b8d --- /dev/null +++ b/mysql-test/std_data/loaddata2.dat @@ -0,0 +1,5 @@ +Field A,'Field B' +Field 1,'Field 2' +Field 3,'Field 4' +'Field 5' ,'Field 6' +Field 6, 'Field 7' diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index e63f0780e3e..732ed248702 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -14,6 +14,7 @@ load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated SELECT * from t1; drop table t1; - - - +create table t1 (a text, b text); +load data infile '../../std_data/loaddata2.dat' into table t1 fields terminated by ',' enclosed by ''''; +select concat('|',a,'|'), concat('|',b,'|') from t1; +drop table t1; diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test index f72a4a504a0..9e1c22ac642 100644 --- a/mysql-test/t/query_cache.test +++ b/mysql-test/t/query_cache.test @@ -10,7 +10,7 @@ flush query cache; # This crashed in some versions flush query cache; # This crashed in some versions reset query cache; flush status; -drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00,mysqltest.t1; +drop table if exists t1,t2,t3; drop database if exists mysqltest; # @@ -450,25 +450,3 @@ select * from t1; show status like "Qcache_queries_in_cache"; SET OPTION SQL_SELECT_LIMIT=DEFAULT; drop table t1; - -# -# more then 255 (257) merged tables test -# -flush status; -disable_query_log; -let $1 = 257; -while ($1) -{ - eval create table t$1(a int); - eval insert into t$1 values (1),(2); - dec $1; -} -create table t00 (a int) type=MERGE UNION=(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257) INSERT_METHOD=FIRST; -enable_query_log; -select count(*) from t00; -select count(*) from t00; -show status like "Qcache_queries_in_cache"; -show status like "Qcache_hits"; -delete from t256; -show status like "Qcache_queries_in_cache"; -drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; diff --git a/mysql-test/t/query_cache_merge.test b/mysql-test/t/query_cache_merge.test new file mode 100644 index 00000000000..9d9e311af06 --- /dev/null +++ b/mysql-test/t/query_cache_merge.test @@ -0,0 +1,38 @@ +# Test query cache with many tables + +--source include/have_query_cache.inc +let $LIMIT=`SHOW VARIABLES LIKE 'open_files_limit'`; +let $MIN_LIMIT=100 +let $MAX_LIMIT=65536 +--source include/check_var_limit.inc + +SET @@global.query_cache_size=1355776; + +# +# more then 255 (257) merged tables test +# + +flush status; +disable_query_log; +--disable_warnings +let $1 = 257; +while ($1) +{ + eval drop table if exists t$1; + eval create table t$1(a int); + eval insert into t$1 values (1),(2); + dec $1; +} +--enable_warnings + +create table t00 (a int) type=MERGE UNION=(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257) INSERT_METHOD=FIRST; +enable_query_log; +select count(*) from t00; +select count(*) from t00; +show status like "Qcache_queries_in_cache"; +show status like "Qcache_hits"; +delete from t256; +show status like "Qcache_queries_in_cache"; +drop table t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15,t16,t17,t18,t19,t20,t21,t22,t23,t24,t25,t26,t27,t28,t29,t30,t31,t32,t33,t34,t35,t36,t37,t38,t39,t40,t41,t42,t43,t44,t45,t46,t47,t48,t49,t50,t51,t52,t53,t54,t55,t56,t57,t58,t59,t60,t61,t62,t63,t64,t65,t66,t67,t68,t69,t70,t71,t72,t73,t74,t75,t76,t77,t78,t79,t80,t81,t82,t83,t84,t85,t86,t87,t88,t89,t90,t91,t92,t93,t94,t95,t96,t97,t98,t99,t100,t101,t102,t103,t104,t105,t106,t107,t108,t109,t110,t111,t112,t113,t114,t115,t116,t117,t118,t119,t120,t121,t122,t123,t124,t125,t126,t127,t128,t129,t130,t131,t132,t133,t134,t135,t136,t137,t138,t139,t140,t141,t142,t143,t144,t145,t146,t147,t148,t149,t150,t151,t152,t153,t154,t155,t156,t157,t158,t159,t160,t161,t162,t163,t164,t165,t166,t167,t168,t169,t170,t171,t172,t173,t174,t175,t176,t177,t178,t179,t180,t181,t182,t183,t184,t185,t186,t187,t188,t189,t190,t191,t192,t193,t194,t195,t196,t197,t198,t199,t200,t201,t202,t203,t204,t205,t206,t207,t208,t209,t210,t211,t212,t213,t214,t215,t216,t217,t218,t219,t220,t221,t222,t223,t224,t225,t226,t227,t228,t229,t230,t231,t232,t233,t234,t235,t236,t237,t238,t239,t240,t241,t242,t243,t244,t245,t246,t247,t248,t249,t250,t251,t252,t253,t254,t255,t256,t257,t00; + +SET @@global.query_cache_size=0; diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test index 206f911d028..904479635c2 100644 --- a/mysql-test/t/select_safe.test +++ b/mysql-test/t/select_safe.test @@ -56,9 +56,9 @@ SELECT * from t1; SELECT @@MAX_SEEKS_FOR_KEY; analyze table t1; insert into t1 values (null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"),(null,"a"); -explain select * from t1,t1 as t2 where t1.b=t2.b; +explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; set MAX_SEEKS_FOR_KEY=1; -explain select * from t1,t1 as t2 where t1.b=t2.b; +explain select STRAIGHT_JOIN * from t1,t1 as t2 where t1.b=t2.b; SET MAX_SEEKS_FOR_KEY=DEFAULT; drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 592252bb294..43481ca0963 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1836,9 +1836,16 @@ double Field_longlong::val_real(void) else #endif longlongget(j,ptr); - return unsigned_flag ? ulonglong2double((ulonglong) j) : (double) j; + /* The following is open coded to avoid a bug in gcc 3.3 */ + if (unsigned_flag) + { + ulonglong tmp= (ulonglong) j; + return ulonglong2double(tmp); + } + return (double) j; } + longlong Field_longlong::val_int(void) { longlong j; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index b90ab1a4a3a..ae5b46671a5 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2158,7 +2158,10 @@ int main(int argc, char **argv) max_connections,table_cache_size)); sql_print_error("Warning: Changed limits: max_connections: %ld table_cache: %ld",max_connections,table_cache_size); } + open_files_limit= files; } +#else + open_files_limit= 0; /* Can't set or detect limit */ #endif unireg_init(opt_specialflag); /* Set up extern variabels */ init_errmessage(); /* Read error messages from file */ @@ -4903,6 +4906,19 @@ static void fix_paths(void) } +/* + set how many open files we want to be able to handle + + SYNOPSIS + set_maximum_open_files() + max_file_limit Files to open + + NOTES + The request may not fulfilled becasue of system limitations + + RETURN + Files available to open +*/ #ifdef SET_RLIMIT_NOFILE static uint set_maximum_open_files(uint max_file_limit) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index ee573672c35..4911b1a6b75 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -767,9 +767,13 @@ int READ_INFO::read_field() row_end= to; return 0; } - /* Copy the found '"' character */ + /* + The string didn't terminate yet. + Store back next character for the loop + */ PUSH(chr); - chr='"'; + /* copy the found term character to 'to' */ + chr= found_enclosed_char; } else if (chr == field_term_char && found_enclosed_char == INT_MAX) { From fdfb10f2fb9855d92be2ad9133a950a94606030f Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Aug 2003 15:39:24 +0200 Subject: [PATCH 072/282] 2 minor edits, plus fix for BUG#1113 "INSERT into non-trans table SELECT ; ROLLBACK" does not send warning" and fix for BUG#873 "In transaction, INSERT to non-trans table is written too early to binlog". Now we don't always write the non-trans update immediately to the binlog; if there is something in the binlog cache we write it to the binlog cache (because the non-trans update could depend on a trans table which was modified earlier in the transaction); then in case of ROLLBACK, we write the binlog cache to the binlog, wrapped with BEGIN/ROLLBACK. This guarantees that the slave does the same updates. For ROLLBACK TO SAVEPOINT: when we execute a SAVEPOINT command we write it to the binlog cache. At ROLLBACK TO SAVEPOINT, if some non-trans table was updated, we write ROLLBACK TO SAVEPOINT to the binlog cache; when the transaction terminates (COMMIT/ROLLBACK), the binlog cache will be flushed to the binlog (because of the non-trans update) so we'll have SAVEPOINT and ROLLBACK TO SAVEPOINT in the binlog. Apart from this rare case of updates of mixed table types in transaction, the usual way is still clear the binlog cache at ROLLBACK, or chop it at ROLLBACK TO SAVEPOINT (meaning the SAVEPOINT command is also chopped, which is fine). Note that BUG#873 encompasses subbugs 1) and 2) of BUG#333 "3 binlogging bugs when doing INSERT with mixed InnoDB/MyISAM". client/mysqldump.c: Minor edit: one CHANGE MASTER with 2 arguments instead of 2 CHANGE MASTER with one argument each. mysql-test/r/rpl_loaddata.result: result update mysql-test/t/rpl_loaddata.test: minor edit: simplifying the test. sql/handler.cc: Fix for BUG#873. See comments in code, and the description of the changeset. sql/log.cc: * Previously, if a query updated a non-transactional table we wrote it immediately to the real binlog. This causes a bug when the update is done inside a transaction and uses the content of an updated transactional table (because this makes a wrong order of queries in the binlog). So if the binlog cache is not empty, we write the query to the binlog cache; otherwise we can write it to the binlog. * Previously, when we flushed the binlog cache to the binlog, we wrapped it with BEGIN/COMMIT. Now it's also possible to wrap it with BEGIN/ROLLBACK, to handle transactions which update both transactional and non-transactional tables. sql/log_event.cc: The slave thread can leave a transaction if COMMIT or if ROLLBACK. sql/sql_class.h: prototype sql/sql_insert.cc: Fix for BUG#1113: this was because the INSERT SELECT code did not set OPTION_STATUS_NO_TRANS_UPDATE. sql/sql_parse.cc: Don't send ER_WARNING_NOT_COMPLETE_ROLLBACK if this is the SQL slave thread (see comments). --- client/mysqldump.c | 5 +- mysql-test/r/mix_innodb_myisam_binlog.result | 180 +++++++++++++++++++ mysql-test/r/rpl_loaddata.result | 6 +- mysql-test/t/mix_innodb_myisam_binlog.test | 175 ++++++++++++++++++ mysql-test/t/rpl_loaddata.test | 14 +- sql/handler.cc | 69 ++++++- sql/log.cc | 31 +++- sql/log_event.cc | 2 +- sql/sql_class.h | 2 +- sql/sql_insert.cc | 4 + sql/sql_parse.cc | 13 +- 11 files changed, 471 insertions(+), 30 deletions(-) create mode 100644 mysql-test/r/mix_innodb_myisam_binlog.result create mode 100644 mysql-test/t/mix_innodb_myisam_binlog.test diff --git a/client/mysqldump.c b/client/mysqldump.c index 459cb9fda31..f1425faf0ed 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -1459,9 +1459,8 @@ int main(int argc, char **argv) fprintf(md_result_file, "\n--\n-- Position to start replication from\n--\n\n"); fprintf(md_result_file, - "CHANGE MASTER TO MASTER_LOG_FILE='%s' ;\n", row[0]); - fprintf(md_result_file, "CHANGE MASTER TO MASTER_LOG_POS=%s ;\n", - row[1]); + "CHANGE MASTER TO MASTER_LOG_FILE='%s', \ +MASTER_LOG_POS=%s ;\n",row[0],row[1]); } mysql_free_result(master); } diff --git a/mysql-test/r/mix_innodb_myisam_binlog.result b/mysql-test/r/mix_innodb_myisam_binlog.result new file mode 100644 index 00000000000..8a3415a81d0 --- /dev/null +++ b/mysql-test/r/mix_innodb_myisam_binlog.result @@ -0,0 +1,180 @@ +drop table if exists ti, tm; +create table ti (a int) type=innodb; +create table tm (a int) type=myisam; +reset master; +begin; +insert into ti values(1); +insert into tm select * from ti; +commit; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(1) +master-bin.001 178 Query 1 79 use test; insert into tm select * from ti +master-bin.001 244 Query 1 244 use test; COMMIT +delete from ti; +delete from tm; +reset master; +begin; +insert into ti values(2); +insert into tm select * from ti; +rollback; +Warning: Some non-transactional changed tables couldn't be rolled back +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(2) +master-bin.001 178 Query 1 79 use test; insert into tm select * from ti +master-bin.001 244 Query 1 244 use test; ROLLBACK +delete from ti; +delete from tm; +reset master; +begin; +insert into ti values(3); +savepoint my_savepoint; +insert into ti values(4); +insert into tm select * from ti; +rollback to savepoint my_savepoint; +Warning: Some non-transactional changed tables couldn't be rolled back +commit; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(3) +master-bin.001 178 Query 1 79 use test; savepoint my_savepoint +master-bin.001 235 Query 1 79 use test; insert into ti values(4) +master-bin.001 294 Query 1 79 use test; insert into tm select * from ti +master-bin.001 360 Query 1 79 use test; rollback to savepoint my_savepoint +master-bin.001 429 Query 1 429 use test; COMMIT +delete from ti; +delete from tm; +reset master; +begin; +insert into ti values(5); +savepoint my_savepoint; +insert into ti values(6); +insert into tm select * from ti; +rollback to savepoint my_savepoint; +Warning: Some non-transactional changed tables couldn't be rolled back +insert into ti values(7); +commit; +select a from ti order by a; +a +5 +7 +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(5) +master-bin.001 178 Query 1 79 use test; savepoint my_savepoint +master-bin.001 235 Query 1 79 use test; insert into ti values(6) +master-bin.001 294 Query 1 79 use test; insert into tm select * from ti +master-bin.001 360 Query 1 79 use test; rollback to savepoint my_savepoint +master-bin.001 429 Query 1 79 use test; insert into ti values(7) +master-bin.001 488 Query 1 488 use test; COMMIT +delete from ti; +delete from tm; +reset master; +select get_lock("a",10); +get_lock("a",10) +1 +begin; +insert into ti values(8); +insert into tm select * from ti; +select get_lock("a",10); +get_lock("a",10) +1 +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(8) +master-bin.001 178 Query 1 79 use test; insert into tm select * from ti +master-bin.001 244 Query 1 244 use test; ROLLBACK +delete from ti; +delete from tm; +reset master; +insert into ti values(9); +insert into tm select * from ti; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; insert into ti values(9) +master-bin.001 138 Query 1 138 use test; insert into tm select * from ti +delete from ti; +delete from tm; +reset master; +insert into ti values(10); +begin; +insert into tm select * from ti; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; insert into ti values(10) +master-bin.001 139 Query 1 139 use test; insert into tm select * from ti +insert into ti values(11); +commit; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; insert into ti values(10) +master-bin.001 139 Query 1 139 use test; insert into tm select * from ti +master-bin.001 205 Query 1 205 use test; BEGIN +master-bin.001 245 Query 1 205 use test; insert into ti values(11) +master-bin.001 305 Query 1 305 use test; COMMIT +alter table tm type=INNODB; +delete from ti; +delete from tm; +reset master; +begin; +insert into ti values(12); +insert into tm select * from ti; +commit; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(12) +master-bin.001 179 Query 1 79 use test; insert into tm select * from ti +master-bin.001 245 Query 1 245 use test; COMMIT +delete from ti; +delete from tm; +reset master; +begin; +insert into ti values(13); +insert into tm select * from ti; +rollback; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +delete from ti; +delete from tm; +reset master; +begin; +insert into ti values(14); +savepoint my_savepoint; +insert into ti values(15); +insert into tm select * from ti; +rollback to savepoint my_savepoint; +commit; +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(14) +master-bin.001 179 Query 1 179 use test; COMMIT +delete from ti; +delete from tm; +reset master; +begin; +insert into ti values(16); +savepoint my_savepoint; +insert into ti values(17); +insert into tm select * from ti; +rollback to savepoint my_savepoint; +insert into ti values(18); +commit; +select a from ti order by a; +a +16 +18 +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.001 79 Query 1 79 use test; BEGIN +master-bin.001 119 Query 1 79 use test; insert into ti values(16) +master-bin.001 179 Query 1 79 use test; insert into ti values(18) +master-bin.001 239 Query 1 239 use test; COMMIT +drop table ti,tm; diff --git a/mysql-test/r/rpl_loaddata.result b/mysql-test/r/rpl_loaddata.result index e93f8487c32..0302381c119 100644 --- a/mysql-test/r/rpl_loaddata.result +++ b/mysql-test/r/rpl_loaddata.result @@ -20,9 +20,9 @@ day id category name 2003-02-22 2461 b a a a @ %  ' " a 2003-03-22 2161 c asdf 2003-04-22 2416 a bbbbb -show binlog events from 898; -Log_name Pos Event_type Server_id Orig_log_pos Info -slave-bin.001 898 Query 1 898 use test; insert into t3 select * from t2 +show master status; +File Position Binlog_do_db Binlog_ignore_db +slave-bin.001 964 drop table t1; drop table t2; drop table t3; diff --git a/mysql-test/t/mix_innodb_myisam_binlog.test b/mysql-test/t/mix_innodb_myisam_binlog.test new file mode 100644 index 00000000000..240aaefb349 --- /dev/null +++ b/mysql-test/t/mix_innodb_myisam_binlog.test @@ -0,0 +1,175 @@ +# Check that binlog is ok when a transaction mixes updates to InnoDB and +# MyISAM. It would be nice to make this a replication test, but in 4.0 the slave +# is always with --skip-innodb in the testsuite. I (Guilhem) however did some +# tests manually on a slave; tables are replicated fine and Exec_master_log_pos +# advances as expected. + +-- source include/have_innodb.inc + +connect (con1,localhost,root,,); +connect (con2,localhost,root,,); + +connection con1; + +drop table if exists ti, tm; +create table ti (a int) type=innodb; +create table tm (a int) type=myisam; + +reset master; + +begin; +insert into ti values(1); +insert into tm select * from ti; +commit; + +show binlog events from 79; + +delete from ti; +delete from tm; +reset master; + +begin; +insert into ti values(2); +insert into tm select * from ti; +# should say some changes to non-transactional tables couldn't be rolled back +--error 1196 +rollback; + +show binlog events from 79; + +delete from ti; +delete from tm; +reset master; + +begin; +insert into ti values(3); +savepoint my_savepoint; +insert into ti values(4); +insert into tm select * from ti; +--error 1196 +rollback to savepoint my_savepoint; +commit; + +show binlog events from 79; + +delete from ti; +delete from tm; +reset master; + +begin; +insert into ti values(5); +savepoint my_savepoint; +insert into ti values(6); +insert into tm select * from ti; +--error 1196 +rollback to savepoint my_savepoint; +insert into ti values(7); +commit; +select a from ti order by a; # check that savepoints work :) + +show binlog events from 79; + +# and when ROLLBACK is not explicit? +delete from ti; +delete from tm; +reset master; + +select get_lock("a",10); +begin; +insert into ti values(8); +insert into tm select * from ti; +disconnect con1; + +connection con2; +# We want to SHOW BINLOG EVENTS, to know what was logged. But there is no +# guarantee that logging of the terminated con1 has been done yet (it may not +# even be started, so con1 may have not even attempted to lock the binlog yet; +# so SHOW BINLOG EVENTS may come before con1 does the loggin. To be sure that +# logging has been done, we use a user lock. +select get_lock("a",10); +show binlog events from 79; + +# and when not in a transaction? +delete from ti; +delete from tm; +reset master; + +insert into ti values(9); +insert into tm select * from ti; + +show binlog events from 79; + +# Check that when the query updating the MyISAM table is the first in the +# transaction, we log it immediately. +delete from ti; +delete from tm; +reset master; + +insert into ti values(10); # first make ti non-empty +begin; +insert into tm select * from ti; +show binlog events from 79; +insert into ti values(11); +commit; + +show binlog events from 79; + + +# Check that things work like before this BEGIN/ROLLBACK code was added, when tm +# is INNODB + +alter table tm type=INNODB; + +delete from ti; +delete from tm; +reset master; + +begin; +insert into ti values(12); +insert into tm select * from ti; +commit; + +show binlog events from 79; + +delete from ti; +delete from tm; +reset master; + +begin; +insert into ti values(13); +insert into tm select * from ti; +rollback; + +show binlog events from 79; + +delete from ti; +delete from tm; +reset master; + +begin; +insert into ti values(14); +savepoint my_savepoint; +insert into ti values(15); +insert into tm select * from ti; +rollback to savepoint my_savepoint; +commit; + +show binlog events from 79; + +delete from ti; +delete from tm; +reset master; + +begin; +insert into ti values(16); +savepoint my_savepoint; +insert into ti values(17); +insert into tm select * from ti; +rollback to savepoint my_savepoint; +insert into ti values(18); +commit; +select a from ti order by a; # check that savepoints work :) + +show binlog events from 79; + +drop table ti,tm; diff --git a/mysql-test/t/rpl_loaddata.test b/mysql-test/t/rpl_loaddata.test index 65e07aaa823..4c4ff6a093e 100644 --- a/mysql-test/t/rpl_loaddata.test +++ b/mysql-test/t/rpl_loaddata.test @@ -32,15 +32,13 @@ sync_with_master; select * from t1; select * from t3; # We want to be sure that LOAD DATA is in the slave's binlog. -# But we can't simply read this binlog, because the file_id is uncertain (would -# cause test failures). So instead, we test if the binlog looks long enough to +# But we can't simply read this binlog, because as the slave has not been +# restarted for this test, the file_id is uncertain (would cause test +# failures). So instead, we test if the binlog looks long enough to # contain LOAD DATA. That is, I (Guilhem) have done SHOW BINLOG EVENTS on my -# machine, saw that the last event is 'create table t3' and is at position 898 -# when things go fine. If LOAD DATA was not logged, the binlog would be shorter -# than 898 bytes and there would be an error in SHOW BINLOG EVENTS. Of course, -# if someone changes the content of '../../std_data/rpl_loaddata2.dat', 898 will -# have to be changed too. -show binlog events from 898; +# machine, saw that the binlog is of size 964 when things go fine. +# If LOAD DATA was not logged, the binlog would be shorter. +show master status; connection master; diff --git a/sql/handler.cc b/sql/handler.cc index 96611301bfa..0d29dbeaa31 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -349,7 +349,7 @@ int ha_commit_trans(THD *thd, THD_TRANS* trans) if (trans == &thd->transaction.all && mysql_bin_log.is_open() && my_b_tell(&thd->transaction.trans_log)) { - mysql_bin_log.write(thd, &thd->transaction.trans_log); + mysql_bin_log.write(thd, &thd->transaction.trans_log, 1); reinit_io_cache(&thd->transaction.trans_log, WRITE_CACHE, (my_off_t) 0, 0, 1); thd->transaction.trans_log.end_of_file= max_binlog_cache_size; @@ -432,9 +432,21 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) } #endif if (trans == &thd->transaction.all) + { + /* + Update the binary log with a BEGIN/ROLLBACK block if we have cached some + queries and we updated some non-transactional table. Such cases should + be rare (updating a non-transactional table inside a transaction...). + */ + if (unlikely((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) && + mysql_bin_log.is_open() && + my_b_tell(&thd->transaction.trans_log))) + mysql_bin_log.write(thd, &thd->transaction.trans_log, 0); + /* Flushed or not, empty the binlog cache */ reinit_io_cache(&thd->transaction.trans_log, - WRITE_CACHE, (my_off_t) 0, 0, 1); - thd->transaction.trans_log.end_of_file= max_binlog_cache_size; + WRITE_CACHE, (my_off_t) 0, 0, 1); + thd->transaction.trans_log.end_of_file= max_binlog_cache_size; + } thd->variables.tx_isolation=thd->session_tx_isolation; if (operation_done) { @@ -448,9 +460,27 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans) /* -Rolls the current transaction back to a savepoint. -Return value: 0 if success, 1 if there was not a savepoint of the given -name. + Rolls the current transaction back to a savepoint. + Return value: 0 if success, 1 if there was not a savepoint of the given + name. + NOTE: how do we handle this (unlikely but legal) case: + [transaction] + [update to non-trans table] + [rollback to savepoint] ? + The problem occurs when a savepoint is before the update to the + non-transactional table. Then when there's a rollback to the savepoint, if we + simply truncate the binlog cache, we lose the part of the binlog cache where + the update is. If we want to not lose it, we need to write the SAVEPOINT + command and the ROLLBACK TO SAVEPOINT command to the binlog cache. The latter + is easy: it's just write at the end of the binlog cache, but the former should + be *inserted* to the place where the user called SAVEPOINT. The solution is + that when the user calls SAVEPOINT, we write it to the binlog cache (so no + need to later insert it). As transactions are never intermixed in the binary log + (i.e. they are serialized), we won't have conflicts with savepoint names when + using mysqlbinlog or in the slave SQL thread. + Then when ROLLBACK TO SAVEPOINT is called, if we updated some + non-transactional table, we don't truncate the binlog cache but instead write + ROLLBACK TO SAVEPOINT to it; otherwise we truncate the binlog cache (which + will chop the SAVEPOINT command from the binlog cache, which is good as in + that case there is no need to have it in the binlog). */ int ha_rollback_to_savepoint(THD *thd, char *savepoint_name) @@ -475,8 +505,24 @@ int ha_rollback_to_savepoint(THD *thd, char *savepoint_name) error=1; } else - reinit_io_cache(&thd->transaction.trans_log, WRITE_CACHE, - binlog_cache_pos, 0, 0); + { + /* + Write ROLLBACK TO SAVEPOINT to the binlog cache if we have updated some + non-transactional table. Otherwise, truncate the binlog cache starting + from the SAVEPOINT command. + */ + if (unlikely((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) && + mysql_bin_log.is_open() && + my_b_tell(&thd->transaction.trans_log))) + { + Query_log_event qinfo(thd, thd->query, thd->query_length, TRUE); + if (mysql_bin_log.write(&qinfo)) + error= 1; + } + else + reinit_io_cache(&thd->transaction.trans_log, WRITE_CACHE, + binlog_cache_pos, 0, 0); + } operation_done=1; #endif if (operation_done) @@ -505,6 +551,13 @@ int ha_savepoint(THD *thd, char *savepoint_name) #ifdef HAVE_INNOBASE_DB innobase_savepoint(thd,savepoint_name, binlog_cache_pos); #endif + /* Write it to the binary log (see comments of ha_rollback_to_savepoint). */ + if (mysql_bin_log.is_open()) + { + Query_log_event qinfo(thd, thd->query, thd->query_length, TRUE); + if (mysql_bin_log.write(&qinfo)) + error= 1; + } } #endif /* USING_TRANSACTIONS */ DBUG_RETURN(error); diff --git a/sql/log.cc b/sql/log.cc index ee774ea3700..6e9fa38c407 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1062,7 +1062,17 @@ bool MYSQL_LOG::write(Log_event* event_info) bool should_rotate = 0; const char *local_db = event_info->get_db(); #ifdef USING_TRANSACTIONS - IO_CACHE *file = ((event_info->get_cache_stmt()) ? + /* + Should we write to the binlog cache or to the binlog on disk? + Write to the binlog cache if: + - it is already not empty (meaning we're in a transaction; note that the + present event could be about a non-transactional table, but still we need + to write to the binlog cache in that case to handle updates to mixed + trans/non-trans table types the best possible in binlogging) + - or if the event asks for it (cache_stmt == true). + */ + IO_CACHE *file = ((event_info->get_cache_stmt() || + my_b_tell(&thd->transaction.trans_log)) ? &thd->transaction.trans_log : &log_file); #else @@ -1258,6 +1268,13 @@ uint MYSQL_LOG::next_file_id() /* Write a cached log entry to the binary log + SYNOPSIS + write() + thd + cache The cache to copy to the binlog + commit_or_rollback If true, will write "COMMIT" in the end, if false will + write "ROLLBACK". + NOTE - We only come here if there is something in the cache. - The thing in the cache is always a complete transaction @@ -1265,10 +1282,13 @@ uint MYSQL_LOG::next_file_id() IMPLEMENTATION - To support transaction over replication, we wrap the transaction - with BEGIN/COMMIT in the binary log. + with BEGIN/COMMIT or BEGIN/ROLLBACK in the binary log. + We want to write a BEGIN/ROLLBACK block when a non-transactional table was + updated in a transaction which was rolled back. This is to ensure that the + same updates are run on the slave. */ -bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) +bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, bool commit_or_rollback) { VOID(pthread_mutex_lock(&LOCK_log)); DBUG_ENTER("MYSQL_LOG::write(cache"); @@ -1322,7 +1342,10 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) */ { - Query_log_event qinfo(thd, "COMMIT", 6, TRUE); + Query_log_event qinfo(thd, + commit_or_rollback ? "COMMIT" : "ROLLBACK", + commit_or_rollback ? 6 : 8, + TRUE); qinfo.set_log_pos(this); if (qinfo.write(&log_file) || flush_io_cache(&log_file)) goto err; diff --git a/sql/log_event.cc b/sql/log_event.cc index 9e7546dd635..54e4d34f77e 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1803,7 +1803,7 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli) */ if (!strcmp(thd->query,"BEGIN")) rli->inside_transaction= opt_using_transactions; - else if (!strcmp(thd->query,"COMMIT")) + else if (!(strcmp(thd->query,"COMMIT") && strcmp(thd->query,"ROLLBACK"))) rli->inside_transaction=0; /* diff --git a/sql/sql_class.h b/sql/sql_class.h index 49a364856eb..b30faa3e9d9 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -140,7 +140,7 @@ public: bool write(THD *thd, const char *query, uint query_length, time_t query_start=0); bool write(Log_event* event_info); // binary log write - bool write(THD *thd, IO_CACHE *cache); + bool write(THD *thd, IO_CACHE *cache, bool commit_or_rollback); /* v stands for vector diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 167ccf974c7..0a83358e8c6 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1367,6 +1367,8 @@ void select_insert::send_error(uint errcode,const char *err) table->file->has_transactions()); mysql_bin_log.write(&qinfo); } + if (!table->tmp_table) + thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; } ha_rollback_stmt(thd); if (info.copied || info.deleted) @@ -1398,6 +1400,8 @@ bool select_insert::send_eof() if (info.copied || info.deleted) { query_cache_invalidate3(thd, table, 1); + if (!(table->file->has_transactions() || table->tmp_table)) + thd->options|=OPTION_STATUS_NO_TRANS_UPDATE; } if (error) { diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 1479a611b5a..548714345f8 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2553,7 +2553,16 @@ mysql_execute_command(void) thd->server_status&= ~SERVER_STATUS_IN_TRANS; if (!ha_rollback(thd)) { - if (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) + /* + If a non-transactional table was updated, warn; don't warn if this is a + slave thread (because when a slave thread executes a ROLLBACK, it has + been read from the binary log, so it's 100% sure and normal to produce + error ER_WARNING_NOT_COMPLETE_ROLLBACK. If we sent the warning to the + slave SQL thread, it would not stop the thread but just be printed in + the error log; but we don't want users to wonder why they have this + message in the error log, so we don't send it. + */ + if ((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) && !thd->slave_thread) send_warning(&thd->net,ER_WARNING_NOT_COMPLETE_ROLLBACK,0); else send_ok(&thd->net); @@ -2565,7 +2574,7 @@ mysql_execute_command(void) case SQLCOM_ROLLBACK_TO_SAVEPOINT: if (!ha_rollback_to_savepoint(thd, lex->savepoint_name)) { - if (thd->options & OPTION_STATUS_NO_TRANS_UPDATE) + if ((thd->options & OPTION_STATUS_NO_TRANS_UPDATE) && !thd->slave_thread) send_warning(&thd->net,ER_WARNING_NOT_COMPLETE_ROLLBACK,0); else send_ok(&thd->net); From 11fbbe44ac160a305d6ca452c6a14ef34a8282b9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Aug 2003 18:32:11 +0300 Subject: [PATCH 073/282] grant.result, grant.test, sql_acl.cc: Fix for a bug #878 sql/sql_acl.cc: Fix for a bug #878 mysql-test/t/grant.test: Fix for a bug #878 mysql-test/r/grant.result: Fix for a bug #878 --- mysql-test/r/grant.result | 20 ++++++++++++++++++++ mysql-test/t/grant.test | 10 ++++++++++ sql/sql_acl.cc | 2 ++ 3 files changed, 32 insertions(+) diff --git a/mysql-test/r/grant.result b/mysql-test/r/grant.result index fccd3715af7..8f9fa13a070 100644 --- a/mysql-test/r/grant.result +++ b/mysql-test/r/grant.result @@ -100,6 +100,26 @@ GRANT SELECT, REFERENCES, REFERENCES (a) ON `test`.`t1` TO 'mysqltest_1'@'localh select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; table_priv column_priv Select,References References +grant all on test.* to user1@localhost with grant option; +revoke all on test.* from user1@localhost; +show grants for user1@localhost; +Grants for user1@localhost +GRANT USAGE ON *.* TO 'user1'@'localhost' +GRANT USAGE ON `test`.* TO 'user1'@'localhost' WITH GRANT OPTION +revoke grant option on test.* from user1@localhost; +show grants for user1@localhost; +Grants for user1@localhost +GRANT USAGE ON *.* TO 'user1'@'localhost' +grant all on test.t1 to user2@localhost with grant option; +revoke all on test.t1 from user2@localhost; +show grants for user2@localhost; +Grants for user2@localhost +GRANT USAGE ON *.* TO 'user2'@'localhost' +GRANT USAGE ON `test`.`t1` TO 'user2'@'localhost' WITH GRANT OPTION +revoke grant option on test.t1 from user2@localhost; +show grants for user2@localhost; +Grants for user2@localhost +GRANT USAGE ON *.* TO 'user2'@'localhost' delete from mysql.user where user='mysqltest_1'; delete from mysql.db where user='mysqltest_1'; delete from mysql.tables_priv where user='mysqltest_1'; diff --git a/mysql-test/t/grant.test b/mysql-test/t/grant.test index 5b20354336c..f278a720cd6 100644 --- a/mysql-test/t/grant.test +++ b/mysql-test/t/grant.test @@ -66,6 +66,16 @@ REVOKE insert,insert (a) on t1 from mysqltest_1@localhost; GRANT references on t1 to mysqltest_1@localhost; show grants for mysqltest_1@localhost; select table_priv,column_priv from mysql.tables_priv where user="mysqltest_1"; +grant all on test.* to user1@localhost with grant option; +revoke all on test.* from user1@localhost; +show grants for user1@localhost; +revoke grant option on test.* from user1@localhost; +show grants for user1@localhost; +grant all on test.t1 to user2@localhost with grant option; +revoke all on test.t1 from user2@localhost; +show grants for user2@localhost; +revoke grant option on test.t1 from user2@localhost; +show grants for user2@localhost; delete from mysql.user where user='mysqltest_1'; delete from mysql.db where user='mysqltest_1'; delete from mysql.tables_priv where user='mysqltest_1'; diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 755a72bec32..fff0883225f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -3049,6 +3049,8 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user) if (test_all_bits(table_access, (TABLE_ACLS & ~GRANT_ACL))) global.append("ALL PRIVILEGES",14); + else if (!(table_access & ~GRANT_ACL)) + global.append("USAGE",5); else { int found= 0; From 619c0d89c6a5162ec4e7cf24a61ee5d38e9300bd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Aug 2003 18:21:23 +0200 Subject: [PATCH 074/282] bug #1078. two innodb+delayed crashes --- mysql-test/r/innodb.result | 12 ++++++++++++ mysql-test/t/innodb.test | 14 ++++++++++++++ sql/sql_insert.cc | 4 ++++ 3 files changed, 30 insertions(+) diff --git a/mysql-test/r/innodb.result b/mysql-test/r/innodb.result index 69268f1d5c5..20cc50dcc61 100644 --- a/mysql-test/r/innodb.result +++ b/mysql-test/r/innodb.result @@ -1329,3 +1329,15 @@ id label 3524 Societe Test 3525 Fournisseur Test drop table t1,t2; +create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) type=innodb; +select * from t1; +c1 c2 stamp +replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); +ERROR HY000: Table storage engine for 't1' doesn't have this option +select * from t1; +c1 c2 stamp +replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); +ERROR HY000: Table storage engine for 't1' doesn't have this option +select * from t1; +c1 c2 stamp +drop table t1; diff --git a/mysql-test/t/innodb.test b/mysql-test/t/innodb.test index 635a15baa41..cd3a5693535 100644 --- a/mysql-test/t/innodb.test +++ b/mysql-test/t/innodb.test @@ -906,3 +906,17 @@ SELECT t2.id, t1.label FROM t2 INNER JOIN (SELECT t1.id_object as id_object FROM t1 WHERE t1.label LIKE '%test%') AS lbl ON (t2.id = lbl.id_object) INNER JOIN t1 ON (t2.id = t1.id_object); drop table t1,t2; + +# +# Bug #1078 +# +create table t1 (c1 char(5) unique not null, c2 int, stamp timestamp) type=innodb; +select * from t1; +--error 1031 +replace delayed into t1 (c1, c2) values ( "text1","11"),( "text2","12"); +select * from t1; +--error 1031 +replace delayed into t1 (c1, c2) values ( "text1","12"),( "text2","13"),( "text3","14", "a" ),( "text4","15", "b" ); +select * from t1; +drop table t1; + diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 947205949f1..6cc5d25c34e 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -172,7 +172,10 @@ int mysql_insert(THD *thd,TABLE_LIST *table_list, else res= (table == 0); else + { + lock_type=TL_WRITE; res= open_and_lock_tables(thd, table_list); + } } else res= open_and_lock_tables(thd, table_list); @@ -627,6 +630,7 @@ public: thd.current_tablenr=0; thd.version=refresh_version; thd.command=COM_DELAYED_INSERT; + thd.lex.current_select= 0; /* for my_message_sql */ bzero((char*) &thd.net,sizeof(thd.net)); // Safety thd.system_thread=1; From 710d4f140a3c0f292f964cc5acc93a9a96318f69 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 22 Aug 2003 23:41:56 +0200 Subject: [PATCH 075/282] added support for --libs_r --- scripts/mysql_config.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 3cc5b3a5016..e8cc9322eaf 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -86,6 +86,8 @@ client_libs='@CLIENT_LIBS@' libs="$ldflags -L'$pkglibdir' -lmysqlclient $client_libs" libs=`echo $libs | sed -e 's; +;;'` +libs_r="$ldflags -L'$pkglibdir' -lmysqlclient_r $client_libs" +libs_r=`echo $libs_r | sed -e 's; +;;'` cflags="-I'$pkgincludedir'" embedded_libs="$ldflags -L'$pkglibdir' -lmysqld @LIBS@ @innodb_system_libs@" @@ -95,6 +97,7 @@ Usage: $0 [OPTIONS] Options: --cflags [$cflags] --libs [$libs] + --libs_r [$libs_r] --socket [$socket] --port [$port] --version [$version] @@ -109,6 +112,7 @@ while test $# -gt 0; do case $1 in --cflags) echo "$cflags" ;; --libs) echo "$libs" ;; + --libs_r) echo "$libs_r" ;; --socket) echo "$socket" ;; --port) echo "$port" ;; --version) echo "$version" ;; From af9b771a32e232788c82f34590c47037c194e177 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Aug 2003 12:25:39 +0300 Subject: [PATCH 076/282] show symlinked directories in SHOW CREATE TABLE --- sql/mysql_priv.h | 1 + sql/mysqld.cc | 8 +++-- sql/sql_show.cc | 92 +++++++++++++++++++++++++++++------------------- sql/sql_table.cc | 3 ++ 4 files changed, 65 insertions(+), 39 deletions(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index e31038d7fee..5e079c40974 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -194,6 +194,7 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); #define MODE_SERIALIZABLE 16 #define MODE_ONLY_FULL_GROUP_BY 32 #define MODE_NO_UNSIGNED_SUBTRACTION 64 +#define MODE_NO_DIR_IN_CREATE 128 #define RAID_BLOCK_SIZE 1024 diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ae5b46671a5..eaecb6e1aa3 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -433,8 +433,12 @@ time_t start_time; ulong opt_sql_mode = 0L; const char *sql_mode_names[] = -{ "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE", - "SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION",NullS }; +{ + "REAL_AS_FLOAT", "PIPES_AS_CONCAT", "ANSI_QUOTES", "IGNORE_SPACE", + "SERIALIZE","ONLY_FULL_GROUP_BY", "NO_UNSIGNED_SUBTRACTION", + "NO_DIR_IN_CREATE", + NullS +}; TYPELIB sql_mode_typelib= {array_elements(sql_mode_names)-1,"", sql_mode_names}; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 515c5da0422..6e7fe650247 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -27,8 +27,6 @@ #include "ha_berkeley.h" // For berkeley_show_logs #endif -/* extern "C" pthread_mutex_t THR_LOCK_keycache; */ - static const char *grant_names[]={ "select","insert","update","delete","create","drop","reload","shutdown", "process","file","grant","references","index","alter"}; @@ -817,17 +815,40 @@ append_identifier(THD *thd, String *packet, const char *name) } } + +/* Append directory name (if exists) to CREATE INFO */ + +static void append_directory(THD *thd, String *packet, const char *dir_type, + const char *filename) +{ + uint length; + if (filename && !(thd->sql_mode & MODE_NO_DIR_IN_CREATE)) + { + length= dirname_length(filename); + packet->append(' '); + packet->append(dir_type); + packet->append(" DIRECTORY='", 12); + packet->append(filename, length); + packet->append('\''); + } +} + + static int store_create_info(THD *thd, TABLE *table, String *packet) { + List field_list; + char tmp[MAX_FIELD_WIDTH], *for_str, buff[128], *end; + String type(tmp, sizeof(tmp)); + Field **ptr,*field; + uint primary_key; + KEY *key_info; + handler *file= table->file; + HA_CREATE_INFO create_info; DBUG_ENTER("store_create_info"); DBUG_PRINT("enter",("table: %s",table->real_name)); restore_record(table,2); // Get empty record - - List field_list; - char tmp[MAX_FIELD_WIDTH]; - String type(tmp, sizeof(tmp)); if (table->tmp_table) packet->append("CREATE TEMPORARY TABLE ", 23); else @@ -835,13 +856,13 @@ store_create_info(THD *thd, TABLE *table, String *packet) append_identifier(thd,packet,table->real_name); packet->append(" (\n", 3); - Field **ptr,*field; for (ptr=table->field ; (field= *ptr); ptr++) { + bool has_default; + uint flags = field->flags; + if (ptr != table->field) packet->append(",\n", 2); - - uint flags = field->flags; packet->append(" ", 2); append_identifier(thd,packet,field->field_name); packet->append(' '); @@ -852,9 +873,9 @@ store_create_info(THD *thd, TABLE *table, String *packet) field->sql_type(type); packet->append(type.ptr(),type.length()); - bool has_default = (field->type() != FIELD_TYPE_BLOB && - field->type() != FIELD_TYPE_TIMESTAMP && - field->unireg_check != Field::NEXT_NUMBER); + has_default= (field->type() != FIELD_TYPE_BLOB && + field->type() != FIELD_TYPE_TIMESTAMP && + field->unireg_check != Field::NEXT_NUMBER); if (flags & NOT_NULL_FLAG) packet->append(" NOT NULL", 9); @@ -880,9 +901,10 @@ store_create_info(THD *thd, TABLE *table, String *packet) packet->append(" auto_increment", 15 ); } - KEY *key_info=table->key_info; - table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); - uint primary_key = table->primary_key; + key_info= table->key_info; + file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); + file->update_create_info(&create_info); + primary_key= table->primary_key; for (uint i=0 ; i < table->keys ; i++,key_info++) { @@ -918,7 +940,6 @@ store_create_info(THD *thd, TABLE *table, String *packet) table->field[key_part->fieldnr-1]->key_length() && !(key_info->flags & HA_FULLTEXT))) { - char buff[64]; buff[0] = '('; char* end=int10_to_str((long) key_part->length, buff + 1,10); *end++ = ')'; @@ -928,43 +949,38 @@ store_create_info(THD *thd, TABLE *table, String *packet) packet->append(')'); } - handler *file = table->file; + /* + Get possible foreign key definitions stored in InnoDB and append them + to the CREATE TABLE statement + */ - /* Get possible foreign key definitions stored in InnoDB and append them - to the CREATE TABLE statement */ - - char* for_str = file->get_foreign_key_create_info(); - - if (for_str) { - packet->append(for_str, strlen(for_str)); - - file->free_foreign_key_create_info(for_str); + if ((for_str= file->get_foreign_key_create_info())) + { + packet->append(for_str, strlen(for_str)); + file->free_foreign_key_create_info(for_str); } packet->append("\n)", 2); packet->append(" TYPE=", 6); packet->append(file->table_type()); - char buff[128]; - char* p; if (table->min_rows) { packet->append(" MIN_ROWS="); - p = longlong10_to_str(table->min_rows, buff, 10); - packet->append(buff, (uint) (p - buff)); + end= longlong10_to_str(table->min_rows, buff, 10); + packet->append(buff, (uint) (end- buff)); } - if (table->max_rows) { packet->append(" MAX_ROWS="); - p = longlong10_to_str(table->max_rows, buff, 10); - packet->append(buff, (uint) (p - buff)); + end= longlong10_to_str(table->max_rows, buff, 10); + packet->append(buff, (uint) (end - buff)); } if (table->avg_row_length) { packet->append(" AVG_ROW_LENGTH="); - p=longlong10_to_str(table->avg_row_length, buff,10); - packet->append(buff, (uint) (p - buff)); + end= longlong10_to_str(table->avg_row_length, buff,10); + packet->append(buff, (uint) (end - buff)); } if (table->db_create_options & HA_OPTION_PACK_KEYS) @@ -989,11 +1005,13 @@ store_create_info(THD *thd, TABLE *table, String *packet) } if (file->raid_type) { - char buff[100]; sprintf(buff," RAID_TYPE=%s RAID_CHUNKS=%d RAID_CHUNKSIZE=%ld", - my_raid_type(file->raid_type), file->raid_chunks, file->raid_chunksize/RAID_BLOCK_SIZE); + my_raid_type(file->raid_type), file->raid_chunks, + file->raid_chunksize/RAID_BLOCK_SIZE); packet->append(buff); } + append_directory(thd, packet, "DATA", create_info.data_file_name); + append_directory(thd, packet, "INDEX", create_info.index_file_name); DBUG_RETURN(0); } diff --git a/sql/sql_table.cc b/sql/sql_table.cc index c55015f7aa5..79105a94dec 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -747,7 +747,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, thd->proc_info="creating table"; + if (thd->sql_mode & MODE_NO_DIR_IN_CREATE) + create_info->data_file_name= create_info->index_file_name= 0; create_info->table_options=db_options; + if (rea_create_table(path, create_info, fields, key_count, key_info_buffer)) { From 6e10224d71cf876466cfa9f83d88fe2c4885f162 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Aug 2003 16:53:04 +0200 Subject: [PATCH 077/282] * Fix for a potential bug: when the SQL thread stops, set rli->inside_transaction to 0. This is needed if the user later restarts replication from a completely different place where there are only autocommit statements. * Detect the case where the master died while flushing the binlog cache to the binlog and stop with error. Cannot add a testcase for this in 4.0 (I tested it manually) as the slave always runs with --skip-innodb. sql/log_event.cc: Detect the case where the master died while flushing the binlog cache to the binlog: in that case, we have a BEGIN with no COMMIT/ROLLBACK in the relay log; we detect this with rli->inside_transaction in Rotate_log_event::exec_event() (which is the only right place to detect this, see comments). When we see it, we stop with error. In 4.1, I had put code in Start_log_event::exec_event(); I'll remove it next time I push in the 4.1 tree. sql/slave.cc: * Use slave_print_error instead of sql_print_error, to put the info in SHOW SLAVE STATUS too. * Fix for a potential bug: when the SQL thread stops, set rli->inside_transaction to 0. This is not needed if replication later restarts from the same position; but this is needed if the user restarts replication from a completely different place where there are only autocommit statements (in that case, if we didn't set to 0, the position would never increment in SHOW SLAVE STATUS, even if queries are processed well). --- sql/log_event.cc | 43 ++++++++++++++++++++++++++++++++++++------- sql/slave.cc | 8 +++++++- 2 files changed, 43 insertions(+), 8 deletions(-) diff --git a/sql/log_event.cc b/sql/log_event.cc index 54e4d34f77e..c3bf41af8e7 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -2068,9 +2068,6 @@ Fatal error running LOAD DATA INFILE on table '%s'. Default database: '%s'", TODO - Remove all active user locks - - If we have an active transaction at this point, the master died - in the middle while writing the transaction to the binary log. - In this case we should stop the slave. */ int Start_log_event::exec_event(struct st_relay_log_info* rli) @@ -2098,8 +2095,10 @@ int Start_log_event::exec_event(struct st_relay_log_info* rli) break; case BINLOG_FORMAT_323_GEQ_57 : /* Can distinguish, based on the value of 'created' */ - if (created) /* this was generated at master startup*/ - close_temporary_tables(thd); + if (!created) + break; + /* otherwise this was generated at master startup*/ + close_temporary_tables(thd); break; default : /* this case is impossible */ @@ -2156,10 +2155,28 @@ int Stop_log_event::exec_event(struct st_relay_log_info* rli) We can't rotate the slave as this will cause infinitive rotations in a A -> B -> A setup. + NOTES + As a transaction NEVER spans on 2 or more binlogs: + if we have an active transaction at this point, the master died while + writing the transaction to the binary log, i.e. while flushing the binlog + cache to the binlog. As the write was started, the transaction had been + committed on the master, so we lack of information to replay this + transaction on the slave; all we can do is stop with error. + If we didn't detect it, then positions would start to become garbage (as we + are incrementing rli->relay_log_pos whereas we are in a transaction: the new + rli->relay_log_pos will be + relay_log_pos of the BEGIN + size of the Rotate event = garbage. + + Since MySQL 4.0.14, the master ALWAYS sends a Rotate event when it starts + sending the next binlog, so we are sure to receive a Rotate event just + after the end of the "dead master"'s binlog; so this exec_event() is the + right place to catch the problem. If we would wait until + Start_log_event::exec_event() it would be too late, rli->relay_log_pos would + already be garbage. + RETURN VALUES 0 ok - */ - +*/ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) { @@ -2167,6 +2184,18 @@ int Rotate_log_event::exec_event(struct st_relay_log_info* rli) DBUG_ENTER("Rotate_log_event::exec_event"); pthread_mutex_lock(&rli->data_lock); + + if (rli->inside_transaction) + { + slave_print_error(rli, 0, + "there is an unfinished transaction in the relay log \ +(could find neither COMMIT nor ROLLBACK in the relay log); it could be that \ +the master died while writing the transaction to its binary log. Now the slave \ +is rolling back the transaction."); + pthread_mutex_unlock(&rli->data_lock); + DBUG_RETURN(1); + } + memcpy(log_name, new_log_ident, ident_len+1); rli->master_log_pos = pos; rli->relay_log_pos += get_event_len(); diff --git a/sql/slave.cc b/sql/slave.cc index 32ed228e119..10ec0050d05 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -2260,7 +2260,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) } else { - sql_print_error("\ + slave_print_error(rli, 0, "\ Could not parse relay log event entry. The possible reasons are: the master's \ binary log is corrupted (you can check this by running 'mysqlbinlog' on the \ binary log), the slave's relay log is corrupted (you can check this by running \ @@ -2695,6 +2695,12 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ DBUG_ASSERT(rli->slave_running == 1); // tracking buffer overrun /* When master_pos_wait() wakes up it will check this and terminate */ rli->slave_running= 0; + /* + Going out of the transaction. Necessary to mark it, in case the user + restarts replication from a non-transactional statement (with CHANGE + MASTER). + */ + rli->inside_transaction= 0; /* Wake up master_pos_wait() */ pthread_mutex_unlock(&rli->data_lock); DBUG_PRINT("info",("Signaling possibly waiting master_pos_wait() functions")); From 89e95d0c2601879ae21fe093d100449098ce3e7e Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Aug 2003 17:41:43 +0200 Subject: [PATCH 078/282] The slave threads MUST not care about max_join_size, we start them with OPTION_BIG_SELECTS. sql/slave.cc: The slave threads MUST not care about max_join_size. I can imagine the case of a slave where users can connect and do SELECTs, but DBA does not want them to issue crazy SELECTs, but he/she still wants replication to work. Before, this just printed a warning to the error log (not fatal) but that was still annoying. --- sql/slave.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 10ec0050d05..66068bec45a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1988,7 +1988,14 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->master_access= ~0; thd->priv_user = 0; thd->slave_thread = 1; - thd->options = (((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | OPTION_AUTO_IS_NULL) ; + thd->options = ((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | + OPTION_AUTO_IS_NULL | + /* + It's nonsense to constraint the slave threads with max_join_size; if a + query succeeded on master, we HAVE to execute it. + */ + OPTION_BIG_SELECTS ; + thd->client_capabilities = CLIENT_LOCAL_FILES; thd->real_id=pthread_self(); pthread_mutex_lock(&LOCK_thread_count); @@ -2008,9 +2015,6 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) VOID(pthread_sigmask(SIG_UNBLOCK,&set,&thd->block_signals)); #endif - if (thd->variables.max_join_size == HA_POS_ERROR) - thd->options |= OPTION_BIG_SELECTS; - if (thd_type == SLAVE_THD_SQL) thd->proc_info= "Waiting for the next event in slave queue"; else From c64d2b6f89a8607ba6905f081eeb4416f15f7dd3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 23 Aug 2003 21:21:02 +0300 Subject: [PATCH 079/282] union.result: same as above sql_lex.h: same as above sql_union.cc: same as aobve sql_select.cc: Fixing that SQL_CALC_FOUND_ROWS work properly in UNION's in 4.1 Plus updating some fields in THD in the proper places plus fixing a wrong result sql/sql_select.cc: Fixing that SQL_CALC_FOUND_ROWS work properly in UNION's in 4.1 Plus updating some fields in THD in the proper places plus fixing a wrong result sql/sql_union.cc: same as aobve sql/sql_lex.h: same as above mysql-test/r/union.result: same as above --- mysql-test/r/union.result | 2 +- sql/sql_lex.h | 4 ++-- sql/sql_select.cc | 5 +++-- sql/sql_union.cc | 39 ++++++++++++++++++++++++--------------- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 396eba7197b..fc72f55172b 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -103,7 +103,7 @@ a b 2 b select found_rows(); found_rows() -6 +8 explain select a,b from t1 union all select a,b from t2; id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t1 ALL NULL NULL NULL NULL 4 diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 506818cdcf9..593f08a4ad1 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -290,8 +290,8 @@ protected: select_result *result; int res; - bool describe, found_rows_for_union, - prepared, // prepare phase already performed for UNION (unit) + ulong describe, found_rows_for_union; + bool prepared, // prepare phase already performed for UNION (unit) optimized, // optimize phase already performed for UNION (unit) executed, // already executed t_and_f; // used for transferring tables_and_fields_initied UNIT:: methods diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 988634fa3d6..f7e5bcf8931 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -941,6 +941,7 @@ JOIN::exec() DBUG_ENTER("JOIN::exec"); error= 0; + thd->limit_found_rows= thd->examined_row_count= 0; if (procedure) { if (procedure->change_columns(fields_list) || @@ -1323,6 +1324,8 @@ JOIN::exec() thd->proc_info="Sending data"; error= thd->net.report_error || do_select(curr_join, curr_fields_list, NULL, procedure); + thd->limit_found_rows= curr_join->send_records; + thd->examined_row_count= curr_join->examined_rows; DBUG_VOID_RETURN; } @@ -1434,8 +1437,6 @@ err: (join->tmp_join->error=join->error,join->tmp_join): join); - thd->limit_found_rows= curr_join->send_records; - thd->examined_row_count= curr_join->examined_rows; thd->proc_info="end"; err= join->cleanup(); if (thd->net.report_error) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index cfed5083b71..b065487fd4f 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -204,7 +204,7 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, select_limit_cnt= sl->select_limit+sl->offset_limit; if (select_limit_cnt < sl->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit - if (select_limit_cnt == HA_POS_ERROR && !sl->braces) + if (select_limit_cnt == HA_POS_ERROR || sl->braces) sl->options&= ~OPTION_FOUND_ROWS; res= join->prepare(&sl->ref_pointer_array, @@ -249,7 +249,7 @@ int st_select_lex_unit::exec() { SELECT_LEX_NODE *lex_select_save= thd->lex.current_select; SELECT_LEX *select_cursor=first_select_in_union(); - unsigned int add_rows=0; + ulonglong add_rows=0; DBUG_ENTER("st_select_lex_unit::exec"); if (executed && !(dependent || uncacheable)) @@ -266,7 +266,7 @@ int st_select_lex_unit::exec() } for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select()) { - unsigned int rows; + ha_rows records_at_start; if (optimized) res= sl->join->reinit(); else @@ -279,12 +279,15 @@ int st_select_lex_unit::exec() select_limit_cnt= sl->select_limit+sl->offset_limit; if (select_limit_cnt < sl->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit - if (select_limit_cnt == HA_POS_ERROR) + if (select_limit_cnt == HA_POS_ERROR || sl->braces) sl->options&= ~OPTION_FOUND_ROWS; - else if (found_rows_for_union) + else { - rows= thd->select_limit; - sl->options|= OPTION_FOUND_ROWS; + /* + We are doing an union without braces. In this case + SQL_CALC_FOUND_ROWS should be done on all sub parts + */ + sl->options|= found_rows_for_union; } res= join->prepare(&sl->ref_pointer_array, @@ -308,6 +311,7 @@ int st_select_lex_unit::exec() } if (!res) { + records_at_start= table->file->records; sl->join->exec(); res= sl->join->error; if (!res && union_result->flush()) @@ -321,8 +325,17 @@ int st_select_lex_unit::exec() thd->lex.current_select= lex_select_save; DBUG_RETURN(res); } - if (found_rows_for_union && !sl->braces && sl->options & OPTION_FOUND_ROWS) - add_rows+= (thd->limit_found_rows > rows) ? thd->limit_found_rows - rows : 0; + if (found_rows_for_union & sl->options) + { + /* + This is a union without braces. Remember the number of rows that could + also have been part of the result set. + We get this from the difference of between total number of possible + rows and actual rows added to the temporary table. + */ + add_rows+= (ulonglong) (thd->limit_found_rows - (table->file->records - + records_at_start)); + } } } optimized= 1; @@ -360,12 +373,8 @@ int st_select_lex_unit::exec() (ORDER*) NULL, NULL, (ORDER*) NULL, thd->options | SELECT_NO_UNLOCK, result, this, fake_select, 0); - if (found_rows_for_union && !res) - { - thd->limit_found_rows= table->file->records; - if (!select_cursor->braces) - thd->limit_found_rows+= add_rows; - } + if (!res) + thd->limit_found_rows = (ulonglong)table->file->records + add_rows; fake_select->exclude(); delete fake_select; /* From 3a068e57245febb37f8d41ddb7da95114c7f704d Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 24 Aug 2003 03:44:16 +0300 Subject: [PATCH 080/282] os0file.c: strerror() does not work in Windows innobase/os/os0file.c: strerror() does not work in Windows --- innobase/os/os0file.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/innobase/os/os0file.c b/innobase/os/os0file.c index 7936b06c24d..311937f2145 100644 --- a/innobase/os/os0file.c +++ b/innobase/os/os0file.c @@ -226,13 +226,8 @@ os_file_get_last_error(void) "InnoDB: the directory. It may also be you have created a subdirectory\n" "InnoDB: of the same name as a data file.\n"); } else { - if (strerror((int)err) != NULL) { - fprintf(stderr, - "InnoDB: Error number %lu means '%s'.\n", err, strerror((int)err)); - } - fprintf(stderr, - "InnoDB: See also section 13.2 at http://www.innodb.com/ibman.html\n" + "InnoDB: See section 13.2 at http://www.innodb.com/ibman.html\n" "InnoDB: about operating system error numbers.\n"); } } From e8007ae77b20a6c51daaa47da78c65fe0b0fdac8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Aug 2003 14:27:32 +0300 Subject: [PATCH 081/282] Update of VC++ project files (to remove link warnings) Fix unlock error in myisamchk on windows when doing --sort-index Use SetFilePointer instead of SetFilePointerEx VC++Files/client/mysql.dsp: Update of project files VC++Files/client/mysqladmin.dsp: Update of project files VC++Files/client/mysqlclient.dsp: Update of project files VC++Files/client/mysqldump.dsp: Update of project files VC++Files/client/mysqlimport.dsp: Update of project files VC++Files/client/mysqlshow.dsp: Update of project files VC++Files/comp_err/comp_err.dsp: Update of project files VC++Files/innobase/innobase.dsp: Update of project files VC++Files/isamchk/isamchk.dsp: Update of project files VC++Files/libmysql/libmysql.dsp: Update of project files VC++Files/libmysqld/libmysqld.dsp: Update of project files VC++Files/libmysqltest/myTest.dsp: Update of project files VC++Files/my_print_defaults/my_print_defaults.dsp: Update of project files VC++Files/myisamlog/myisamlog.dsp: Update of project files VC++Files/mysql.dsw: Update of project files VC++Files/mysqlbinlog/mysqlbinlog.dsp: Update of project files VC++Files/mysqlcheck/mysqlcheck.dsp: Update of project files VC++Files/mysqldemb/mysqldemb.dsp: Update of project files VC++Files/mysqlmanager/MySqlManager.dsp: Update of project files VC++Files/mysqlserver/mysqlserver.dsp: Update of project files VC++Files/mysqlshutdown/mysqlshutdown.dsp: Update of project files VC++Files/mysys/mysys.dsp: Update of project files VC++Files/pack_isam/pack_isam.dsp: Update of project files VC++Files/perror/perror.dsp: Update of project files VC++Files/replace/replace.dsp: Update of project files VC++Files/sql/mysqld.dsp: Update of project files VC++Files/test1/test1.dsp: Update of project files VC++Files/thr_test/thr_test.dsp: Update of project files VC++Files/vio/vio.dsp: Update of project files VC++Files/zlib/zlib.dsp: Update of project files myisam/mi_check.c: Fix unlock error in myisamchk on windows when doing --sort-index myisam/mi_locking.c: Fix unlock error in myisamchk on windows when doing --sort-index myisam/myisamchk.c: New comment mysys/my_chsize.c: Use SetFilePointer instead of SetFilePointerEx, as the first is more portable sql/handler.cc: Fix compiler warning sql/log_event.cc: Fix compiler warning --- VC++Files/client/mysql.dsp | 8 +++---- VC++Files/client/mysqladmin.dsp | 8 +++---- VC++Files/client/mysqlclient.dsp | 8 +++---- VC++Files/client/mysqldump.dsp | 12 +++++----- VC++Files/client/mysqlimport.dsp | 10 ++++----- VC++Files/client/mysqlshow.dsp | 12 +++++----- VC++Files/comp_err/comp_err.dsp | 8 +++---- VC++Files/innobase/innobase.dsp | 18 +++++++-------- VC++Files/isamchk/isamchk.dsp | 8 +++---- VC++Files/libmysql/libmysql.dsp | 2 +- VC++Files/libmysqld/libmysqld.dsp | 14 ++++++------ VC++Files/libmysqltest/myTest.dsp | 8 +++---- .../my_print_defaults/my_print_defaults.dsp | 22 +++++++++---------- VC++Files/myisamlog/myisamlog.dsp | 10 ++++----- VC++Files/mysql.dsw | 3 --- VC++Files/mysqlbinlog/mysqlbinlog.dsp | 12 +++++----- VC++Files/mysqlcheck/mysqlcheck.dsp | 16 +++++++------- VC++Files/mysqldemb/mysqldemb.dsp | 10 ++++----- VC++Files/mysqlmanager/MySqlManager.dsp | 8 +++---- VC++Files/mysqlserver/mysqlserver.dsp | 12 +++++----- VC++Files/mysqlshutdown/mysqlshutdown.dsp | 10 ++++----- VC++Files/mysys/mysys.dsp | 14 ++++++------ VC++Files/pack_isam/pack_isam.dsp | 8 +++---- VC++Files/perror/perror.dsp | 12 +++++----- VC++Files/replace/replace.dsp | 8 +++---- VC++Files/sql/mysqld.dsp | 14 ++++++------ VC++Files/test1/test1.dsp | 8 +++---- VC++Files/thr_test/thr_test.dsp | 8 +++---- VC++Files/vio/vio.dsp | 12 +++++----- VC++Files/zlib/zlib.dsp | 8 +++---- myisam/mi_check.c | 17 +++++++++----- myisam/mi_locking.c | 6 ++++- myisam/myisamchk.c | 5 +++++ mysys/my_chsize.c | 7 +++--- sql/handler.cc | 4 ++-- sql/log_event.cc | 2 -- 36 files changed, 181 insertions(+), 171 deletions(-) diff --git a/VC++Files/client/mysql.dsp b/VC++Files/client/mysql.dsp index 1cd03ee2fcc..9910718778e 100644 --- a/VC++Files/client/mysql.dsp +++ b/VC++Files/client/mysql.dsp @@ -25,7 +25,7 @@ CFG=mysql - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysql - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_release/mysql.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes @@ -68,14 +68,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysql.exe" /pdbtype:sept /libpath:"..\lib_debug\\" diff --git a/VC++Files/client/mysqladmin.dsp b/VC++Files/client/mysqladmin.dsp index 11189ecb065..2c762cd8a24 100644 --- a/VC++Files/client/mysqladmin.dsp +++ b/VC++Files/client/mysqladmin.dsp @@ -25,7 +25,7 @@ CFG=mysqladmin - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqladmin - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqladmin.exe" /libpath:"..\lib_release\\" @@ -67,14 +67,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqladmin.exe" /pdbtype:sept /libpath:"..\lib_debug\\" diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp index 99bc3296f95..28693f32e95 100644 --- a/VC++Files/client/mysqlclient.dsp +++ b/VC++Files/client/mysqlclient.dsp @@ -25,7 +25,7 @@ CFG=mysqlclient - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqlclient - Win32 Release" @@ -48,7 +48,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_release\mysqlclient.lib" @@ -65,14 +65,14 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /ZI /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /D "USE_TLS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /D "USE_TLS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_debug\mysqlclient.lib" diff --git a/VC++Files/client/mysqldump.dsp b/VC++Files/client/mysqldump.dsp index 4fae9a5769a..d36664e09ce 100644 --- a/VC++Files/client/mysqldump.dsp +++ b/VC++Files/client/mysqldump.dsp @@ -25,7 +25,7 @@ CFG=mysqldump - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqldump - Win32 Release" @@ -42,14 +42,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /GX- /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqldump.exe" /libpath:"..\lib_release\\" @@ -67,16 +67,16 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /GX- /ZI /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_debug/mysqldump.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqldump.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ENDIF diff --git a/VC++Files/client/mysqlimport.dsp b/VC++Files/client/mysqlimport.dsp index 8eb08f1411f..a8b239d226f 100644 --- a/VC++Files/client/mysqlimport.dsp +++ b/VC++Files/client/mysqlimport.dsp @@ -25,7 +25,7 @@ CFG=mysqlimport - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqlimport - Win32 Release" @@ -42,14 +42,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /GX- /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlimport.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /incremental:yes @@ -68,14 +68,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /GX- /ZI /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlimport.exe" /pdbtype:sept /libpath:"..\lib_debug\\" diff --git a/VC++Files/client/mysqlshow.dsp b/VC++Files/client/mysqlshow.dsp index 78627246050..26705465fec 100644 --- a/VC++Files/client/mysqlshow.dsp +++ b/VC++Files/client/mysqlshow.dsp @@ -25,7 +25,7 @@ CFG=mysqlshow - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqlshow - Win32 Release" @@ -42,14 +42,14 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MT /W3 /GX- /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /I "../" /D "NDEBUG" /D "DBUG_OFF" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "NDEBUG" # ADD RSC /l 0x409 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlshow.exe" /libpath:"..\lib_release\\" @@ -67,16 +67,16 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /GX- /ZI /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" +# ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlshow.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ENDIF diff --git a/VC++Files/comp_err/comp_err.dsp b/VC++Files/comp_err/comp_err.dsp index 71582b84763..deaf0627262 100644 --- a/VC++Files/comp_err/comp_err.dsp +++ b/VC++Files/comp_err/comp_err.dsp @@ -24,7 +24,7 @@ CFG=comp_err - Win32 Release # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 @@ -33,8 +33,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c @@ -44,7 +44,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ..\lib_release\mysys.lib wsock32.lib ..\lib_release\strings.lib ..\lib_release\dbug.lib /nologo /subsystem:console /machine:I386 /nodefaultlib:"LIBC.lib" /out:"Release/comp-err.exe" # Begin Target diff --git a/VC++Files/innobase/innobase.dsp b/VC++Files/innobase/innobase.dsp index 2018b15be82..83419fc53cc 100644 --- a/VC++Files/innobase/innobase.dsp +++ b/VC++Files/innobase/innobase.dsp @@ -27,7 +27,7 @@ CFG=INNOBASE - WIN32 RELEASE # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "innobase - Win32 Debug" @@ -50,7 +50,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo /out:"..\lib_release\innobase-nt.lib" # ADD LIB32 /nologo /out:"..\lib_debug\innodb.lib" @@ -74,7 +74,7 @@ LIB32=link.exe -lib BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo /out:"..\lib_release\innodb.lib" # ADD LIB32 /nologo /out:"..\lib_release\innodb.lib" @@ -87,8 +87,8 @@ LIB32=link.exe -lib # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "innobase___Win32_nt" -# PROP Intermediate_Dir "innobase___Win32_nt" +# PROP Output_Dir "nt" +# PROP Intermediate_Dir "nt" # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c @@ -98,7 +98,7 @@ LIB32=link.exe -lib BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo /out:"..\lib_release\innodb.lib" # ADD LIB32 /nologo /out:"..\lib_release\innodb.lib" @@ -111,8 +111,8 @@ LIB32=link.exe -lib # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "innobase___Win32_Max_nt" -# PROP Intermediate_Dir "innobase___Win32_Max_nt" +# PROP Output_Dir "max_nt" +# PROP Intermediate_Dir "max_nt" # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /GX /O2 /I "../innobase/include" /I "../include" /D "NDEBUG" /D "_LIB" /D "_WIN32" /D "WIN32" /D "_MBCS" /D "MYSQL_SERVER" /FD /c @@ -122,7 +122,7 @@ LIB32=link.exe -lib BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo /out:"..\lib_release\innodb.lib" # ADD LIB32 /nologo /out:"..\lib_release\innodb.lib" diff --git a/VC++Files/isamchk/isamchk.dsp b/VC++Files/isamchk/isamchk.dsp index e1e0f8aac3a..0e8e2b04bd7 100644 --- a/VC++Files/isamchk/isamchk.dsp +++ b/VC++Files/isamchk/isamchk.dsp @@ -25,7 +25,7 @@ CFG=isamchk - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "isamchk - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /machine:I386 /out:"../client_release/isamchk.exe" # SUBTRACT LINK32 /pdb:none @@ -68,14 +68,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /I "../isam" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../isam" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x41d /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/isamchk.exe" /pdbtype:sept # SUBTRACT LINK32 /verbose /pdb:none diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp index 43dee62061f..923cac29c37 100644 --- a/VC++Files/libmysql/libmysql.dsp +++ b/VC++Files/libmysql/libmysql.dsp @@ -76,7 +76,7 @@ PostBuild_Cmds=xcopy release\libmysql.lib ..\lib_release /y # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "." /I "..\include" /I "../zlib" /D "_DEBUG" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "." /I "..\include" /I "../zlib" /D "_DEBUG" /D "_WINDOWS" /D "SAFE_MUTEX" /D "USE_TLS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 diff --git a/VC++Files/libmysqld/libmysqld.dsp b/VC++Files/libmysqld/libmysqld.dsp index 843bc0bd95f..d2614ae4858 100644 --- a/VC++Files/libmysqld/libmysqld.dsp +++ b/VC++Files/libmysqld/libmysqld.dsp @@ -25,7 +25,7 @@ CFG=libmysqld - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe MTL=midl.exe RSC=rc.exe @@ -38,8 +38,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBMYSQLD_EXPORTS" /YX /FD /c @@ -51,7 +51,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\myisam.lib ..\lib_release\myisammrg.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib ..\lib_release\innodb.lib ..\lib_release\bdb.lib ..\lib_release\zlib.lib /nologo /dll /machine:I386 /out:"../lib_release/libmysqld.dll" /implib:"../lib_release/libmysqld.lib" # SUBTRACT LINK32 /pdb:none @@ -70,7 +70,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBMYSQLD_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /MT /W3 /Gm /Zi /Od /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_BERKELEY_DB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /D "__WIN__" /FD /GZ /c +# ADD CPP /nologo /MT /W3 /Z7 /Od /I "../include" /I "../sql" /I "../regex" /I "../bdb/build_win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "HAVE_BERKELEY_DB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /D "__WIN__" /FD /GZ /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x416 /d "_DEBUG" @@ -78,9 +78,9 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_debug\dbug.lib ..\lib_debug\mysys.lib ..\lib_debug\strings.lib ..\lib_debug\regex.lib ..\lib_debug\heap.lib ..\lib_debug\innodb.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib:"LIBCMTD" /out:"../lib_debug/libmysqld.dll" /implib:"../lib_debug/libmysqld.lib" /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_debug\dbug.lib ..\lib_debug\mysys.lib ..\lib_debug\strings.lib ..\lib_debug\regex.lib ..\lib_debug\heap.lib ..\lib_debug\innodb.lib /nologo /dll /incremental:no /debug /machine:I386 /nodefaultlib:"LIBCMTD" /out:"../lib_debug/libmysqld.dll" /implib:"../lib_debug/libmysqld.lib" /pdbtype:sept # SUBTRACT LINK32 /pdb:none !ENDIF diff --git a/VC++Files/libmysqltest/myTest.dsp b/VC++Files/libmysqltest/myTest.dsp index 744b2c04993..1d3a790edd5 100644 --- a/VC++Files/libmysqltest/myTest.dsp +++ b/VC++Files/libmysqltest/myTest.dsp @@ -25,7 +25,7 @@ CFG=myTest - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myTest - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 libmysql.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /libpath:"..\lib_release" @@ -67,14 +67,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "..\include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "..\include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /c # SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 libmysql.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept /libpath:"..\lib_debug" diff --git a/VC++Files/my_print_defaults/my_print_defaults.dsp b/VC++Files/my_print_defaults/my_print_defaults.dsp index b485a20a844..25f5332eb0f 100644 --- a/VC++Files/my_print_defaults/my_print_defaults.dsp +++ b/VC++Files/my_print_defaults/my_print_defaults.dsp @@ -25,7 +25,7 @@ CFG=my_print_defaults - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "my_print_defaults - Win32 Release" @@ -37,8 +37,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /I "../include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c @@ -47,9 +47,9 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386 +LINK32=xilink6.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386 !ELSEIF "$(CFG)" == "my_print_defaults - Win32 Debug" @@ -64,16 +64,16 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /MT /W3 /Gm /GX /ZI /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /MT /W3 /GX /Z7 /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c # ADD BASE RSC /l 0x416 /d "_DEBUG" # ADD RSC /l 0x416 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBCMTD.lib" /pdbtype:sept +LINK32=xilink6.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /nodefaultlib:"LIBCMTD.lib" /pdbtype:sept !ENDIF diff --git a/VC++Files/myisamlog/myisamlog.dsp b/VC++Files/myisamlog/myisamlog.dsp index bbb6739cb16..6df65add63c 100644 --- a/VC++Files/myisamlog/myisamlog.dsp +++ b/VC++Files/myisamlog/myisamlog.dsp @@ -25,7 +25,7 @@ CFG=myisamlog - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "myisamlog - Win32 Release" @@ -37,8 +37,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c @@ -48,7 +48,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib setargv.obj /nologo /subsystem:console /pdb:"release/myisamchk.pdb" /machine:I386 /out:"../client_release/myisamlog.exe" # SUBTRACT LINK32 /pdb:none @@ -74,7 +74,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /pdb:"debug/myisamchk.pdb" /debug /machine:I386 /out:"../client_debug/myisamlog.exe" /pdbtype:sept # SUBTRACT LINK32 /pdb:none diff --git a/VC++Files/mysql.dsw b/VC++Files/mysql.dsw index 9903c91ba1b..eef82588fa8 100644 --- a/VC++Files/mysql.dsw +++ b/VC++Files/mysql.dsw @@ -605,9 +605,6 @@ Package=<5> Package=<4> {{{ - Begin Project Dependency - Project_Dep_Name strings - End Project Dependency }}} ############################################################################### diff --git a/VC++Files/mysqlbinlog/mysqlbinlog.dsp b/VC++Files/mysqlbinlog/mysqlbinlog.dsp index a4e85becd49..b26b911af77 100644 --- a/VC++Files/mysqlbinlog/mysqlbinlog.dsp +++ b/VC++Files/mysqlbinlog/mysqlbinlog.dsp @@ -25,7 +25,7 @@ CFG=mysqlbinlog - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqlbinlog - Win32 Release" @@ -37,8 +37,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "eelease" +# PROP Intermediate_Dir "eelease" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c @@ -48,7 +48,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlbinlog.exe" /libpath:"..\lib_release\\" # SUBTRACT LINK32 /pdb:none /debug @@ -67,13 +67,13 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /I "../" /I "../sql" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "MYSQL_SERVER" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /I "../sql" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "MYSQL_SERVER" /FD /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlbinlog.exe" /pdbtype:sept /libpath:"..\lib_debug\\" diff --git a/VC++Files/mysqlcheck/mysqlcheck.dsp b/VC++Files/mysqlcheck/mysqlcheck.dsp index 9b821261672..f8487119da3 100644 --- a/VC++Files/mysqlcheck/mysqlcheck.dsp +++ b/VC++Files/mysqlcheck/mysqlcheck.dsp @@ -25,7 +25,7 @@ CFG=mysqlcheck - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqlcheck - Win32 Release" @@ -38,7 +38,7 @@ RSC=rc.exe # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Intermediate_Dir "release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c @@ -48,8 +48,8 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +LINK32=xilink6.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/mysqlcheck.exe" /libpath:"..\lib_release\\" !ELSEIF "$(CFG)" == "mysqlcheck - Win32 Debug" @@ -65,15 +65,15 @@ LINK32=link.exe # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "MYSQL_SERVER" /FD /c +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /D "MYSQL_SERVER" /FD /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +LINK32=xilink6.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 mysqlclient.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqlcheck.exe" /pdbtype:sept /libpath:"..\lib_debug\\" !ENDIF diff --git a/VC++Files/mysqldemb/mysqldemb.dsp b/VC++Files/mysqldemb/mysqldemb.dsp index 67de948b9ad..3d27f5cfc7f 100644 --- a/VC++Files/mysqldemb/mysqldemb.dsp +++ b/VC++Files/mysqldemb/mysqldemb.dsp @@ -25,7 +25,7 @@ CFG=mysqldemb - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqldemb - Win32 Release" @@ -38,7 +38,7 @@ RSC=rc.exe # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Intermediate_Dir "release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MT /W3 /O2 /I "../include" /I "../regex" /I "../sql" /I "../bdb/build_win32" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "MYSQL_SERVER" /D "HAVE_INNOBASE_DB" /D "DBUG_OFF" /D "USE_TLS" /D "__WIN__" /FD /c @@ -48,7 +48,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo @@ -65,14 +65,14 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /Zi /Od /I "../include" /I "../regex" /I "../sql" /I "../bdb/build_win32" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "MYSQL_SERVER" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /D "__WIN__" /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Z7 /Od /I "../include" /I "../regex" /I "../sql" /I "../bdb/build_win32" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "MYSQL_SERVER" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /D "__WIN__" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x416 /d "_DEBUG" # ADD RSC /l 0x416 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo diff --git a/VC++Files/mysqlmanager/MySqlManager.dsp b/VC++Files/mysqlmanager/MySqlManager.dsp index f5b62bdabc9..1397c4878af 100644 --- a/VC++Files/mysqlmanager/MySqlManager.dsp +++ b/VC++Files/mysqlmanager/MySqlManager.dsp @@ -25,7 +25,7 @@ CFG=MySqlManager - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe MTL=midl.exe RSC=rc.exe @@ -52,7 +52,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 /nologo /subsystem:windows /machine:I386 # ADD LINK32 /nologo /subsystem:windows /machine:I386 /out:"../client_release/MySqlManager.exe" # SUBTRACT LINK32 /nodefaultlib @@ -71,7 +71,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_AFXDLL" /Yu"stdafx.h" /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /GR /GX /Zi /Od /I "../include" /D "_DEBUG" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /GR /GX /Z7 /Od /I "../include" /D "_DEBUG" /D "_WINDOWS" /FD /c # SUBTRACT CPP /Fr /YX /Yc /Yu # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /o "NUL" /win32 @@ -81,7 +81,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib /nologo /subsystem:windows /incremental:no /debug /machine:I386 /out:"../client_debug/MySqlManager.exe" /pdbtype:sept /libpath:"..\lib_debug\\" # SUBTRACT LINK32 /pdb:none diff --git a/VC++Files/mysqlserver/mysqlserver.dsp b/VC++Files/mysqlserver/mysqlserver.dsp index 0ef59eb226e..d8df71ebbb2 100644 --- a/VC++Files/mysqlserver/mysqlserver.dsp +++ b/VC++Files/mysqlserver/mysqlserver.dsp @@ -25,7 +25,7 @@ CFG=mysqlserver - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqlserver - Win32 Release" @@ -37,8 +37,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /MT /W3 /O2 /I "../include" /I "../regex" /I "../sql" /I "../bdb/build_win32" /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_BERKELEY_DB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "DBUG_OFF" /D "USE_TLS" /YX /FD /c @@ -47,7 +47,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo @@ -64,13 +64,13 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /MTd /W3 /Gm /Zi /Od /I "../include" /I "../regex" /I "../sql" /I "../bdb/build_win32" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_BERKELEY_DB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /YX /FD /GZ /c +# ADD CPP /nologo /MTd /W3 /Z7 /Od /I "../include" /I "../regex" /I "../sql" /I "../bdb/build_win32" /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /D "HAVE_BERKELEY_DB" /D "USE_SYMDIR" /D "SIGNAL_WITH_VIO_CLOSE" /D "HAVE_DLOPEN" /D "EMBEDDED_LIBRARY" /D "HAVE_INNOBASE_DB" /D "USE_TLS" /YX /FD /GZ /c # ADD BASE RSC /l 0x416 /d "_DEBUG" # ADD RSC /l 0x416 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo diff --git a/VC++Files/mysqlshutdown/mysqlshutdown.dsp b/VC++Files/mysqlshutdown/mysqlshutdown.dsp index fd78c6ddb21..d4dd389e99d 100644 --- a/VC++Files/mysqlshutdown/mysqlshutdown.dsp +++ b/VC++Files/mysqlshutdown/mysqlshutdown.dsp @@ -25,7 +25,7 @@ CFG=mysqlshutdown - Win32 Release # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe MTL=midl.exe RSC=rc.exe @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /W3 /GX- /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# ADD CPP /nologo /G6 /W3 /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -52,7 +52,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"../client_release/mysqlshutdown.exe" @@ -72,7 +72,7 @@ LINK32=link.exe # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT BASE CPP /YX -# ADD CPP /nologo /G6 /W3 /GX- /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c +# ADD CPP /nologo /G6 /W3 /Z7 /O2 /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -81,7 +81,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"../client_release/mysqlshutdown.exe" # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /out:"../client_debug/mysqlshutdown.exe" diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp index bc6e70fc339..695e2cb2638 100644 --- a/VC++Files/mysys/mysys.dsp +++ b/VC++Files/mysys/mysys.dsp @@ -26,7 +26,7 @@ CFG=mysys - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysys - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_release\mysys.lib" @@ -66,14 +66,14 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /ZI /Od /I "../include" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /D "USE_SYMDIR" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../zlib" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /D "USE_SYMDIR" /FD /c # SUBTRACT CPP /Fr # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_debug\mysys.lib" @@ -86,8 +86,8 @@ LIB32=link.exe -lib # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "mysys___Win32_Max" -# PROP Intermediate_Dir "mysys___Win32_Max" +# PROP Output_Dir "max" +# PROP Intermediate_Dir "max" # PROP Target_Dir "" # ADD BASE CPP /nologo /G6 /MT /W3 /O2 /I "../include" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c # SUBTRACT BASE CPP /YX @@ -98,7 +98,7 @@ LIB32=link.exe -lib BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo /out:"..\lib_release\mysys.lib" # ADD LIB32 /nologo /out:"..\lib_release\mysys-max.lib" diff --git a/VC++Files/pack_isam/pack_isam.dsp b/VC++Files/pack_isam/pack_isam.dsp index 25e4ef4a2e0..cdcba702e15 100644 --- a/VC++Files/pack_isam/pack_isam.dsp +++ b/VC++Files/pack_isam/pack_isam.dsp @@ -25,7 +25,7 @@ CFG=pack_isam - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "pack_isam - Win32 Release" @@ -48,7 +48,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /machine:I386 /out:"../client_release/pack_isam.exe" @@ -66,14 +66,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /I "../isam" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../isam" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /Fr # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /debug /machine:I386 /out:"../client_debug/pack_isam.exe" /pdbtype:sept diff --git a/VC++Files/perror/perror.dsp b/VC++Files/perror/perror.dsp index 6d5c96b2a84..99bd8f67ae2 100644 --- a/VC++Files/perror/perror.dsp +++ b/VC++Files/perror/perror.dsp @@ -25,7 +25,7 @@ CFG=perror - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe MTL=midl.exe RSC=rc.exe @@ -38,8 +38,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c @@ -52,7 +52,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"../client_release/perror.exe" # SUBTRACT LINK32 /pdb:none @@ -71,7 +71,7 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /GZ /c # SUBTRACT CPP /YX # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 @@ -80,7 +80,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /incremental:no /debug /machine:I386 /pdbtype:sept # SUBTRACT LINK32 /pdb:none diff --git a/VC++Files/replace/replace.dsp b/VC++Files/replace/replace.dsp index f0c4848156a..2fe763ff388 100644 --- a/VC++Files/replace/replace.dsp +++ b/VC++Files/replace/replace.dsp @@ -25,7 +25,7 @@ CFG=replace - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "replace - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /machine:I386 /out:"../client_release/replace.exe" @@ -67,14 +67,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x40b /d "_DEBUG" # ADD RSC /l 0x40b /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib wsock32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib setargv.obj /nologo /subsystem:console /incremental:no /machine:I386 /out:"../client_debug/replace.exe" /pdbtype:sept # SUBTRACT LINK32 /debug diff --git a/VC++Files/sql/mysqld.dsp b/VC++Files/sql/mysqld.dsp index 7942f98dde0..0da3d936df9 100644 --- a/VC++Files/sql/mysqld.dsp +++ b/VC++Files/sql/mysqld.dsp @@ -28,7 +28,7 @@ CFG=mysqld - Win32 Release # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "mysqld - Win32 Release" @@ -52,7 +52,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\vio.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"../client_release/mysqld-opt.exe" # SUBTRACT LINK32 /debug @@ -71,14 +71,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /I "../regex" /I "../bdb/build_win32" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /I "../regex" /I "../bdb/build_win32" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "HAVE_INNOBASE_DB" /D "HAVE_BERKELEY_DB" /D "MYSQL_SERVER" /D "_WINDOWS" /D "_CONSOLE" /D "_MBCS" /D "USE_SYMDIR" /D "HAVE_DLOPEN" /FD /c # SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x410 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_debug\dbug.lib ..\lib_debug\vio.lib ..\lib_debug\isam.lib ..\lib_debug\merge.lib ..\lib_debug\mysys.lib ..\lib_debug\strings.lib ..\lib_debug\regex.lib ..\lib_debug\heap.lib ..\lib_debug\bdb.lib ..\lib_debug\innodb.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /out:"../client_debug/mysqld.exe" /pdbtype:sept @@ -105,7 +105,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\dbug.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib /nologo /subsystem:console /debug /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\vio.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\myisam.lib ..\lib_release\myisammrg.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib ..\lib_release\innodb.lib ..\lib_release\zlib.lib /nologo /subsystem:console /map /machine:I386 /out:"../client_release/mysqld-nt.exe" # SUBTRACT LINK32 /pdb:none /debug @@ -133,7 +133,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\myisam.lib ..\lib_release\myisammrg.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib ..\lib_release\zlib.lib /nologo /subsystem:console /map /machine:I386 /out:"../client_release/mysqld-nt.exe" # SUBTRACT BASE LINK32 /pdb:none /debug # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\vio.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\myisam.lib ..\lib_release\myisammrg.lib ..\lib_release\mysys-max.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib ..\lib_release\zlib.lib ..\lib_release\innodb.lib ..\lib_release\bdb.lib /nologo /subsystem:console /map /machine:I386 /out:"../client_release/mysqld-max-nt.exe" @@ -162,7 +162,7 @@ LINK32=link.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\mysys.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib /nologo /subsystem:console /pdb:none /debug /machine:I386 /out:"../client_release/mysqld-opt.exe" # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib Wsock32.lib ..\lib_release\vio.lib ..\lib_release\isam.lib ..\lib_release\merge.lib ..\lib_release\myisam.lib ..\lib_release\myisammrg.lib ..\lib_release\mysys-max.lib ..\lib_release\strings.lib ..\lib_release\regex.lib ..\lib_release\heap.lib ..\lib_release\innodb.lib ..\lib_release\bdb.lib ..\lib_release\zlib.lib /nologo /subsystem:console /pdb:none /machine:I386 /out:"../client_release/mysqld-max.exe" # SUBTRACT LINK32 /debug diff --git a/VC++Files/test1/test1.dsp b/VC++Files/test1/test1.dsp index fb70ceda692..df4b31d684e 100644 --- a/VC++Files/test1/test1.dsp +++ b/VC++Files/test1/test1.dsp @@ -25,7 +25,7 @@ CFG=test1 - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "test1 - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 @@ -67,14 +67,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /YX # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 libmysql.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept /libpath:"..\lib_debug" # SUBTRACT LINK32 /incremental:no diff --git a/VC++Files/thr_test/thr_test.dsp b/VC++Files/thr_test/thr_test.dsp index a7854a66049..0c80de42521 100644 --- a/VC++Files/thr_test/thr_test.dsp +++ b/VC++Files/thr_test/thr_test.dsp @@ -25,7 +25,7 @@ CFG=thr_test - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "thr_test - Win32 Release" @@ -49,7 +49,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # SUBTRACT LINK32 /nodefaultlib @@ -68,14 +68,14 @@ LINK32=link.exe # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /ZI /Od /I "../include" /D "__WIN32__" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /D "__WIN32__" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_CONSOLE" /D "_MBCS" /D "_WINDOWS" /FD /c # SUBTRACT CPP /Fr /YX # ADD BASE RSC /l 0x40b /d "_DEBUG" # ADD RSC /l 0x40b /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LINK32=link.exe +LINK32=xilink6.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /incremental:no /debug /machine:I386 /pdbtype:sept diff --git a/VC++Files/vio/vio.dsp b/VC++Files/vio/vio.dsp index 50c920a465d..c250e693995 100644 --- a/VC++Files/vio/vio.dsp +++ b/VC++Files/vio/vio.dsp @@ -25,7 +25,7 @@ CFG=vio - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "vio - Win32 Release" @@ -37,8 +37,8 @@ RSC=rc.exe # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" +# PROP Output_Dir "release" +# PROP Intermediate_Dir "release" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c # ADD CPP /nologo /G6 /MT /W3 /O2 /I "../include" /D "NDEBUG" /D "DBUG_OFF" /D "_WINDOWS" /FD /c @@ -47,7 +47,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_release\vio.lib" @@ -64,13 +64,13 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "Debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c -# ADD CPP /nologo /G6 /MTd /W3 /ZI /Od /I "../include" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /D "USE_SYMDIR" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /I "../include" /D "_DEBUG" /D "SAFEMALLOC" /D "SAFE_MUTEX" /D "_WINDOWS" /D "USE_SYMDIR" /FD /c # ADD BASE RSC /l 0x409 /d "_DEBUG" # ADD RSC /l 0x409 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_debug\vio.lib" diff --git a/VC++Files/zlib/zlib.dsp b/VC++Files/zlib/zlib.dsp index fd9d6b2bd68..40aaadaa4e1 100644 --- a/VC++Files/zlib/zlib.dsp +++ b/VC++Files/zlib/zlib.dsp @@ -25,7 +25,7 @@ CFG=zlib - Win32 Debug # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" -CPP=cl.exe +CPP=xicl6.exe RSC=rc.exe !IF "$(CFG)" == "zlib - Win32 Release" @@ -48,7 +48,7 @@ RSC=rc.exe BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_release\zlib.lib" @@ -65,13 +65,13 @@ LIB32=link.exe -lib # PROP Intermediate_Dir "debug" # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /Z7 /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Zi /Od /D "_DEBUG" /D "__WIN32__" /D "_WINDOWS" /FD /c +# ADD CPP /nologo /G6 /MTd /W3 /Z7 /Od /D "_DEBUG" /D "__WIN32__" /D "_WINDOWS" /FD /c # ADD BASE RSC /l 0x409 # ADD RSC /l 0x409 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo -LIB32=link.exe -lib +LIB32=xilink6.exe -lib # ADD BASE LIB32 /nologo # ADD LIB32 /nologo /out:"..\lib_debug\zlib.lib" diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 0d7d7fae628..106e65e90d3 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1513,6 +1513,7 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) File new_file; my_off_t index_pos[MI_MAX_POSSIBLE_KEY]; uint r_locks,w_locks; + int old_lock; MYISAM_SHARE *share=info->s; MI_STATE_INFO old_state; DBUG_ENTER("sort_index"); @@ -1556,8 +1557,11 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) flush_key_blocks(share->kfile, FLUSH_IGNORE_CHANGED); share->state.version=(ulong) time((time_t*) 0); - old_state=share->state; /* save state if not stored */ - r_locks=share->r_locks; w_locks=share->w_locks; + old_state= share->state; /* save state if not stored */ + r_locks= share->r_locks; + w_locks= share->w_locks; + old_lock= info->lock_type; + /* Put same locks as old file */ share->r_locks= share->w_locks= share->tot_locks= 0; (void) _mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE); @@ -1568,12 +1572,13 @@ int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) MYF(0)) || mi_open_keyfile(share)) goto err2; - info->lock_type=F_UNLCK; /* Force mi_readinfo to lock */ + info->lock_type= F_UNLCK; /* Force mi_readinfo to lock */ _mi_readinfo(info,F_WRLCK,0); /* Will lock the table */ - info->lock_type=F_WRLCK; - share->r_locks=r_locks; share->w_locks=w_locks; + info->lock_type= old_lock; + share->r_locks= r_locks; + share->w_locks= w_locks; share->tot_locks= r_locks+w_locks; - share->state=old_state; /* Restore old state */ + share->state= old_state; /* Restore old state */ info->state->key_file_length=param->new_file_pos; info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED); diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 22772a3dd2e..19fd99779ba 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -35,6 +35,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) MYISAM_SHARE *share=info->s; uint flag; DBUG_ENTER("mi_lock_database"); + DBUG_PRINT("info",("lock_type: %d", lock_type)); if (share->options & HA_OPTION_READ_ONLY_DATA || info->lock_type == lock_type) @@ -53,10 +54,13 @@ int mi_lock_database(MI_INFO *info, int lock_type) { switch (lock_type) { case F_UNLCK: + DBUG_PRINT("info", ("old lock: %d", info->lock_type)); if (info->lock_type == F_RDLCK) count= --share->r_locks; - else + else if (info->lock_type == F_WRLCK) count= --share->w_locks; + else + count= 1; /* F_EXTRA_LCK */ --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && !share->delay_key_write && flush_key_blocks(share->kfile,FLUSH_KEEP)) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index a0b4515f1dd..a41292aeb04 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -882,6 +882,11 @@ static int myisamchk(MI_CHECK *param, my_string filename) param->error_printed=0; goto end2; } + /* + _mi_readinfo() has locked the table. + We mark the table as locked (without doing file locks) to be able to + use functions that only works on locked tables (like row caching). + */ mi_lock_database(info, F_EXTRA_LCK); datafile=info->dfile; diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index 11187cf4522..8e46b0808c0 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -51,10 +51,11 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) #if defined(HAVE_SETFILEPOINTER) /* This is for the moment only true on windows */ { - LARGE_INTEGER new_length; HANDLE win_file= (HANDLE) _get_osfhandle(fd); - new_length.QuadPart = newlength; - if (SetFilePointerEx(win_file,new_length,NULL,FILE_BEGIN)) + long length_low, length_high; + length_low= (long) (ulong) newlength; + length_high= (long) ((ulonglong) newlength >> 32); + if (SetFilePointer(win_file, length_low, &length_high, FILE_BEGIN)) { if (SetEndOfFile(win_file)) DBUG_RETURN(0); diff --git a/sql/handler.cc b/sql/handler.cc index 0d29dbeaa31..56cbddff66b 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1079,7 +1079,7 @@ void ha_key_cache(void) changes. */ pthread_mutex_lock(&LOCK_global_system_variables); - long tmp= keybuff_size; + long tmp= (long) keybuff_size; pthread_mutex_unlock(&LOCK_global_system_variables); if (tmp) (void) init_key_cache(tmp); @@ -1089,7 +1089,7 @@ void ha_key_cache(void) void ha_resize_key_cache(void) { pthread_mutex_lock(&LOCK_global_system_variables); - long tmp= keybuff_size; + long tmp= (long) keybuff_size; pthread_mutex_unlock(&LOCK_global_system_variables); (void) resize_key_cache(tmp); } diff --git a/sql/log_event.cc b/sql/log_event.cc index 54e4d34f77e..6b8c1e2db1d 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -1860,8 +1860,6 @@ Default database: '%s'", */ } /* End of if (db_ok(... */ -end: - VOID(pthread_mutex_lock(&LOCK_thread_count)); thd->db= 0; // prevent db from being freed thd->query= 0; // just to be sure From c47ee569159e2bf3c29901df461293aef09403ec Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Aug 2003 14:13:58 +0200 Subject: [PATCH 082/282] Clearer states in SHOW PROCESSLIST for replication threads. For example the Binlog_dump thread (on the master) sometimes showed "Slave:". And there were confusing messages where "binlog" was employed instead of "relay log". sql/log.cc: MYSQL_LOG::wait_for_update() is used by the binlog_dump and I/Oslave threads, and it updates thd->proc_info, so we need a bool to not show the same proc_info for 2 different things (previously we showed "Slave: etc" and that's bad for a binlog_dump thread). sql/slave.cc: Clearer thd-proc_info for slave threads. sql/sql_class.h: prototype change sql/sql_repl.cc: clearer thd->proc_info for binlog_dump thread --- sql/log.cc | 11 +++++++++-- sql/slave.cc | 33 +++++++++++++++++++++------------ sql/sql_class.h | 2 +- sql/sql_repl.cc | 14 +++++++------- 4 files changed, 38 insertions(+), 22 deletions(-) diff --git a/sql/log.cc b/sql/log.cc index 6e9fa38c407..ce06092cfb7 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1526,6 +1526,9 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length, SYNOPSIS wait_for_update() thd Thread variable + master_or_slave If 0, the caller is the Binlog_dump thread from master; + if 1, the caller is the SQL thread from the slave. This + influences only thd->proc_info. NOTES One must have a lock on LOCK_log before calling this function. @@ -1538,11 +1541,15 @@ bool MYSQL_LOG::write(THD *thd,const char *query, uint query_length, */ -void MYSQL_LOG:: wait_for_update(THD* thd) +void MYSQL_LOG:: wait_for_update(THD* thd, bool master_or_slave) { safe_mutex_assert_owner(&LOCK_log); const char* old_msg = thd->enter_cond(&update_cond, &LOCK_log, - "Slave: waiting for binlog update"); + master_or_slave ? + "Has read all relay log; waiting for \ +the I/O slave thread to update it" : + "Has sent all binlog to slave; \ +waiting for binlog to be updated"); pthread_cond_wait(&update_cond, &LOCK_log); pthread_mutex_unlock(&LOCK_log); // See NOTES thd->exit_cond(old_msg); diff --git a/sql/slave.cc b/sql/slave.cc index 66068bec45a..07c9bb7bd8a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1443,7 +1443,8 @@ static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) pthread_mutex_lock(&rli->log_space_lock); const char* save_proc_info= thd->enter_cond(&rli->log_space_cond, &rli->log_space_lock, - "Waiting for relay log space to free"); + "Waiting for the SQL slave \ +thread to free enough relay log space"); while (rli->log_space_limit < rli->log_space_total && !(slave_killed=io_slave_killed(thd,mi)) && !rli->ignore_log_space_limit) @@ -1925,7 +1926,8 @@ int st_relay_log_info::wait_for_pos(THD* thd, String* log_name, DBUG_PRINT("info",("Waiting for master update")); const char* msg = thd->enter_cond(&data_cond, &data_lock, - "Waiting for master update"); + "Waiting for the SQL slave thread to \ +advance position"); /* We are going to pthread_cond_(timed)wait(); if the SQL thread stops it will wake us up. @@ -2016,7 +2018,7 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) #endif if (thd_type == SLAVE_THD_SQL) - thd->proc_info= "Waiting for the next event in slave queue"; + thd->proc_info= "Waiting for the next event in relay log"; else thd->proc_info= "Waiting for master update"; thd->version=refresh_version; @@ -2338,7 +2340,7 @@ slave_begin: } - thd->proc_info = "connecting to master"; + thd->proc_info = "Connecting to master"; // we can get killed during safe_connect if (!safe_connect(thd, mysql, mi)) sql_print_error("Slave I/O thread: connected to master '%s@%s:%d',\ @@ -2385,7 +2387,7 @@ dump"); goto err; } - thd->proc_info = "Waiiting to reconnect after a failed dump request"; + thd->proc_info= "Waiting to reconnect after a failed binlog dump request"; mc_end_server(mysql); /* First time retry immediately, assuming that we can recover @@ -2406,7 +2408,7 @@ dump"); goto err; } - thd->proc_info = "Reconnecting after a failed dump request"; + thd->proc_info = "Reconnecting after a failed binlog dump request"; if (!suppress_warnings) sql_print_error("Slave I/O thread: failed dump request, \ reconnecting to try again, log '%s' at postion %s", IO_RPL_LOG_NAME, @@ -2425,7 +2427,13 @@ after reconnect"); while (!io_slave_killed(thd,mi)) { bool suppress_warnings= 0; - thd->proc_info = "Reading master update"; + /* + We say "waiting" because read_event() will wait if there's nothing to + read. But if there's something to read, it will not wait. The important + thing is to not confuse users by saying "reading" whereas we're in fact + receiving nothing. + */ + thd->proc_info = "Waiting for master to send event"; ulong event_len = read_event(mysql, mi, &suppress_warnings); if (io_slave_killed(thd,mi)) { @@ -2452,7 +2460,8 @@ max_allowed_packet", mc_mysql_error(mysql)); goto err; } - thd->proc_info = "Waiting to reconnect after a failed read"; + thd->proc_info = "Waiting to reconnect after a failed master event \ +read"; mc_end_server(mysql); if (retry_count++) { @@ -2468,7 +2477,7 @@ max_allowed_packet", reconnect after a failed read"); goto err; } - thd->proc_info = "Reconnecting after a failed read"; + thd->proc_info = "Reconnecting after a failed master event read"; if (!suppress_warnings) sql_print_error("Slave I/O thread: Failed reading log event, \ reconnecting to retry, log '%s' position %s", IO_RPL_LOG_NAME, @@ -2485,7 +2494,7 @@ reconnect done to recover from failed read"); } // if (event_len == packet_error) retry_count=0; // ok event, reset retry counter - thd->proc_info = "Queueing event from master"; + thd->proc_info = "Queueing master event to the relay log"; if (queue_event(mi,(const char*)mysql->net.read_pos + 1, event_len)) { @@ -2667,7 +2676,7 @@ log '%s' at position %s, relay log '%s' position: %s", RPL_LOG_NAME, while (!sql_slave_killed(thd,rli)) { - thd->proc_info = "Processing master log event"; + thd->proc_info = "Reading event from the relay log"; DBUG_ASSERT(rli->sql_thd == thd); THD_CHECK_SENTRY(thd); if (exec_relay_log_event(thd,rli)) @@ -3396,7 +3405,7 @@ rli->relay_log_pos=%s rli->pending=%lu", pthread_mutex_unlock(&rli->log_space_lock); pthread_cond_broadcast(&rli->log_space_cond); // Note that wait_for_update unlocks lock_log ! - rli->relay_log.wait_for_update(rli->sql_thd); + rli->relay_log.wait_for_update(rli->sql_thd, 1); // re-acquire data lock since we released it earlier pthread_mutex_lock(&rli->data_lock); continue; diff --git a/sql/sql_class.h b/sql/sql_class.h index 9bf4dc852d7..64a314911ec 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -123,7 +123,7 @@ public: } void set_max_size(ulong max_size_arg); void signal_update() { pthread_cond_broadcast(&update_cond);} - void wait_for_update(THD* thd); + void wait_for_update(THD* thd, bool master_or_slave); void set_need_start_event() { need_start_event = 1; } void init(enum_log_type log_type_arg, enum cache_type io_cache_type_arg, diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 5a42614dff4..10581431c72 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -532,7 +532,7 @@ Increase max_allowed_packet on master"; if (!thd->killed) { /* Note that the following call unlocks lock_log */ - mysql_bin_log.wait_for_update(thd); + mysql_bin_log.wait_for_update(thd, 0); } else pthread_mutex_unlock(log_lock); @@ -547,7 +547,7 @@ Increase max_allowed_packet on master"; if (read_packet) { - thd->proc_info = "sending update to slave"; + thd->proc_info = "Sending binlog event to slave"; if (my_net_write(net, (char*)packet->ptr(), packet->length()) ) { errmsg = "Failed on my_net_write()"; @@ -584,7 +584,7 @@ Increase max_allowed_packet on master"; { bool loop_breaker = 0; // need this to break out of the for loop from switch - thd->proc_info = "switching to next log"; + thd->proc_info = "Finished reading one binlog; switching to next binlog"; switch (mysql_bin_log.find_next_log(&linfo, 1)) { case LOG_INFO_EOF: loop_breaker = (flags & BINLOG_DUMP_NON_BLOCK); @@ -623,14 +623,14 @@ end: (void)my_close(file, MYF(MY_WME)); send_eof(&thd->net); - thd->proc_info = "waiting to finalize termination"; + thd->proc_info = "Waiting to finalize termination"; pthread_mutex_lock(&LOCK_thread_count); thd->current_linfo = 0; pthread_mutex_unlock(&LOCK_thread_count); DBUG_VOID_RETURN; err: - thd->proc_info = "waiting to finalize termination"; + thd->proc_info = "Waiting to finalize termination"; end_io_cache(&log); /* Exclude iteration through thread list @@ -866,7 +866,7 @@ int change_master(THD* thd, MASTER_INFO* mi) DBUG_RETURN(1); } - thd->proc_info = "changing master"; + thd->proc_info = "Changing master"; LEX_MASTER_INFO* lex_mi = &thd->lex.mi; // TODO: see if needs re-write if (init_master_info(mi, master_info_file, relay_log_info_file, 0)) @@ -932,7 +932,7 @@ int change_master(THD* thd, MASTER_INFO* mi) if (need_relay_log_purge) { mi->rli.skip_log_purge= 0; - thd->proc_info="purging old relay logs"; + thd->proc_info="Purging old relay logs"; if (purge_relay_logs(&mi->rli, thd, 0 /* not only reset, but also reinit */, &errmsg)) From 3b799e8fd8eb13c7ad6e2bb01a922e37d9101ea7 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Aug 2003 16:40:14 +0300 Subject: [PATCH 083/282] removed --rpl option of ./mysql-test-run (./mysql-test-run t/rpl*.test do same work) --- mysql-test/mysql-test-run.sh | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 874abdc0c86..f11cad4a13e 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -210,7 +210,6 @@ CHARACTER_SET=latin1 DBUSER="" START_WAIT_TIMEOUT=10 STOP_WAIT_TIMEOUT=10 -TEST_REPLICATION=0 MYSQL_TEST_SSL_OPTS="" while test $# -gt 0; do @@ -288,9 +287,6 @@ while test $# -gt 0; do --user-test=*) USER_TEST=`$ECHO "$1" | $SED -e "s;--user-test=;;"` ;; - --rpl) - TEST_REPLICATION=1 - ;; --mysqld=*) TMP=`$ECHO "$1" | $SED -e "s;--mysqld=;;"` EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT $TMP" @@ -1407,17 +1403,10 @@ then if [ x$RECORD = x1 ]; then $ECHO "Will not run in record mode without a specific test case." else - if [ x$TEST_REPLICATION = x1 ]; then - for tf in `ls -1 $TESTDIR/*.$TESTSUFFIX | $SORT` - do - run_testcase $tf - done - else - for tf in $TESTDIR/*.$TESTSUFFIX - do - run_testcase $tf - done - fi + for tf in $TESTDIR/*.$TESTSUFFIX + do + run_testcase $tf + done $RM -f $TIMEFILE # Remove for full test fi else From 76438bd1bb07979badbd05048b7bb4a1b9fb333a Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Aug 2003 17:07:14 +0300 Subject: [PATCH 084/282] symlink.result: Fix for a small error in the merge from 4.0 mysql-test/r/symlink.result: Fix for a small error in the merge from 4.0 --- mysql-test/r/symlink.result | 2 -- 1 file changed, 2 deletions(-) diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index 216fb4d6124..4469ca36941 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -46,8 +46,6 @@ alter table t8 rename t7; rename table t7 to t9; drop table t1; Got one of the listed errors -Warnings: -Note 1008 Can't drop database 'test_mysqltest'; database doesn't exist Got one of the listed errors Got one of the listed errors Got one of the listed errors From 413b57e14c23b42b1068fd6a95a5e1296029acd1 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Aug 2003 17:19:44 +0300 Subject: [PATCH 085/282] Better fix for myisamchk --sort-index on windows Fixed deadlock bug when doing resize of key buffer while key buffer was in active use myisam/mi_locking.c: Better fix for myisamchk --sort-index on windows mysql-test/r/symlink.result: Update results mysql-test/t/symlink.test: Update results mysys/mf_keycache.c: Fixed deadlock bug when doing resize of key buffer while key buffer was in active use sql/ha_myisam.cc: simple optimization sql/sql_show.cc: Fixed theoretical buffer overrun Reset variable properly before calling update_create_info() --- myisam/mi_locking.c | 33 +++++++++++++++++---------------- mysql-test/r/symlink.result | 4 ++-- mysql-test/t/symlink.test | 2 ++ mysys/mf_keycache.c | 18 +++++++++++++----- sql/ha_myisam.cc | 2 +- sql/sql_show.cc | 11 +++++++---- 6 files changed, 42 insertions(+), 28 deletions(-) diff --git a/myisam/mi_locking.c b/myisam/mi_locking.c index 19fd99779ba..18daebffa85 100644 --- a/myisam/mi_locking.c +++ b/myisam/mi_locking.c @@ -57,10 +57,8 @@ int mi_lock_database(MI_INFO *info, int lock_type) DBUG_PRINT("info", ("old lock: %d", info->lock_type)); if (info->lock_type == F_RDLCK) count= --share->r_locks; - else if (info->lock_type == F_WRLCK) - count= --share->w_locks; else - count= 1; /* F_EXTRA_LCK */ + count= --share->w_locks; --share->tot_locks; if (info->lock_type == F_WRLCK && !share->w_locks && !share->delay_key_write && flush_key_blocks(share->kfile,FLUSH_KEEP)) @@ -110,19 +108,22 @@ int mi_lock_database(MI_INFO *info, int lock_type) if (error) mi_mark_crashed(info); } - if (share->r_locks) - { /* Only read locks left */ - flag=1; - if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF, - MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) - error=my_errno; - } - else if (!share->w_locks) - { /* No more locks */ - flag=1; - if (my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF, - MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) - error=my_errno; + if (info->lock_type != F_EXTRA_LCK) + { + if (share->r_locks) + { /* Only read locks left */ + flag=1; + if (my_lock(share->kfile,F_RDLCK,0L,F_TO_EOF, + MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) + error=my_errno; + } + else if (!share->w_locks) + { /* No more locks */ + flag=1; + if (my_lock(share->kfile,F_UNLCK,0L,F_TO_EOF, + MYF(MY_WME | MY_SEEK_NOT_DONE)) && !error) + error=my_errno; + } } } info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); diff --git a/mysql-test/r/symlink.result b/mysql-test/r/symlink.result index ab699ac4c4e..2deecae7243 100644 --- a/mysql-test/r/symlink.result +++ b/mysql-test/r/symlink.result @@ -40,7 +40,7 @@ t9 CREATE TABLE `t9` ( `b` char(16) NOT NULL default '', `c` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM +) TYPE=MyISAM DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' alter table t9 rename t8, add column d int not null; alter table t8 rename t7; rename table t7 to t9; @@ -62,5 +62,5 @@ t9 CREATE TABLE `t9` ( `c` int(11) NOT NULL default '0', `d` int(11) NOT NULL default '0', PRIMARY KEY (`a`) -) TYPE=MyISAM +) TYPE=MyISAM DATA DIRECTORY='TEST_DIR/var/tmp/' INDEX DIRECTORY='TEST_DIR/var/run/' drop database mysqltest; diff --git a/mysql-test/t/symlink.test b/mysql-test/t/symlink.test index d8bba12b645..5e1fe313a7e 100644 --- a/mysql-test/t/symlink.test +++ b/mysql-test/t/symlink.test @@ -46,6 +46,7 @@ check table t9; optimize table t9; repair table t9; alter table t9 add column c int not null; +--replace_result $MYSQL_TEST_DIR TEST_DIR show create table t9; # Test renames @@ -86,5 +87,6 @@ enable_query_log; alter table t9 rename mysqltest.t9; select count(*) from mysqltest.t9; +--replace_result $MYSQL_TEST_DIR TEST_DIR show create table mysqltest.t9; drop database mysqltest; diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 6a037f13f05..4cb3681b8b8 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -705,11 +705,19 @@ int flush_key_blocks(File file, enum flush_type type) static int flush_all_key_blocks() { - int error=0; - while (_my_blocks_changed > 0) - if (flush_key_blocks_int(_my_used_first->file, FLUSH_RELEASE)) - error=1; - return error; + SEC_LINK **block, **end; + for (block= changed_blocks, end= block+CHANGED_BLOCKS_HASH; + block < end; + block++ + ) + { + while (*block) + { + if (flush_key_blocks_int((*block)->file, FLUSH_RELEASE)) + return 1; + } + } + return 0; } diff --git a/sql/ha_myisam.cc b/sql/ha_myisam.cc index 9059ad803f8..97c002cee52 100644 --- a/sql/ha_myisam.cc +++ b/sql/ha_myisam.cc @@ -1018,7 +1018,7 @@ THR_LOCK_DATA **ha_myisam::store_lock(THD *thd, void ha_myisam::update_create_info(HA_CREATE_INFO *create_info) { - table->file->info(HA_STATUS_AUTO | HA_STATUS_CONST); + ha_myisam::info(HA_STATUS_AUTO | HA_STATUS_CONST); if (!(create_info->used_fields & HA_CREATE_USED_AUTO)) { create_info->auto_increment_value=auto_increment_value; diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6e7fe650247..6680485ef0c 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -903,6 +903,7 @@ store_create_info(THD *thd, TABLE *table, String *packet) key_info= table->key_info; file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); + bzero((char*) &create_info, sizeof(create_info)); file->update_create_info(&create_info); primary_key= table->primary_key; @@ -1005,10 +1006,12 @@ store_create_info(THD *thd, TABLE *table, String *packet) } if (file->raid_type) { - sprintf(buff," RAID_TYPE=%s RAID_CHUNKS=%d RAID_CHUNKSIZE=%ld", - my_raid_type(file->raid_type), file->raid_chunks, - file->raid_chunksize/RAID_BLOCK_SIZE); - packet->append(buff); + uint length; + length= my_snprintf(buff,sizeof(buff), + " RAID_TYPE=%s RAID_CHUNKS=%d RAID_CHUNKSIZE=%ld", + my_raid_type(file->raid_type), file->raid_chunks, + file->raid_chunksize/RAID_BLOCK_SIZE); + packet->append(buff, length); } append_directory(thd, packet, "DATA", create_info.data_file_name); append_directory(thd, packet, "INDEX", create_info.index_file_name); From 3fdc38d4bba14827ef13f70235622450e6e10418 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 25 Aug 2003 16:20:21 +0200 Subject: [PATCH 086/282] comments about mutexes in replication. Don't start the SQL slave thread with SQL_BIG_SELECTS; it's better to inhibate max_join_size instead. sql/slave.cc: OPTION_BIG_SELECTS does more than ignoring max_join_size (talks to the optimiser), just ignore max_join_size. sql/slave.h: comments --- sql/slave.cc | 13 ++++++------- sql/slave.h | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/sql/slave.cc b/sql/slave.cc index 07c9bb7bd8a..1bc8dfc5b78 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1991,13 +1991,12 @@ static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type) thd->priv_user = 0; thd->slave_thread = 1; thd->options = ((opt_log_slave_updates) ? OPTION_BIN_LOG:0) | - OPTION_AUTO_IS_NULL | - /* - It's nonsense to constraint the slave threads with max_join_size; if a - query succeeded on master, we HAVE to execute it. - */ - OPTION_BIG_SELECTS ; - + OPTION_AUTO_IS_NULL; + /* + It's nonsense to constraint the slave threads with max_join_size; if a + query succeeded on master, we HAVE to execute it. + */ + thd->variables.max_join_size= HA_POS_ERROR; thd->client_capabilities = CLIENT_LOCAL_FILES; thd->real_id=pthread_self(); pthread_mutex_lock(&LOCK_thread_count); diff --git a/sql/slave.h b/sql/slave.h index 19411aba497..67bf009763b 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -24,6 +24,30 @@ having to re-read the master updates. */ +/* + MUTEXES in replication: + + LOCK_active_mi: this is meant for multimaster, when we can switch from a + master to another. It protects active_mi. We don't care of it for the moment, + as active_mi never moves (it's created at startup and deleted at shutdown, and + not changed: it always points to the same MASTER_INFO struct), because we + don't have multimaster. So for the moment, mi does not move, and mi->rli does + not either. + + In MASTER_INFO: run_lock, data_lock + run_lock protects all information about the run state: slave_running, and the + existence of the I/O thread (to stop/start it, you need this mutex). + data_lock protects some moving members of the struct: counters (log name, + position) and relay log (MYSQL_LOG object). + + In RELAY_LOG_INFO: run_lock, data_lock + see MASTER_INFO + + In MYSQL_LOG: LOCK_log, LOCK_index of the binlog and the relay log + LOCK_log: when you write to it. LOCK_index: when you create/delete a binlog + (so that you have to update the .index file). +*/ + extern ulong slave_net_timeout, master_retry_count; extern MY_BITMAP slave_error_mask; extern bool use_slave_mask; From 7a21caabab32c3cce0357fbccf772b2af482d470 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Aug 2003 14:29:13 +0200 Subject: [PATCH 087/282] - Reverted a fix for bug#897, as it broke the installation on some other operating systems - some implementations of "hostname" simply set the host name to "-f" instead of giving an error about an unkown option --- scripts/mysql_install_db.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh index ffb857933cd..920bd27cc88 100644 --- a/scripts/mysql_install_db.sh +++ b/scripts/mysql_install_db.sh @@ -107,13 +107,8 @@ then fi fi -# Try to determine the fully qualified domain name (FQDN) -HOSTNAME="@HOSTNAME@" -if $HOSTNAME -f > /dev/null 2>&1 ; then - hostname=`$HOSTNAME -f` -else - hostname=`$HOSTNAME` -fi +# Try to determine the hostname +hostname=`@HOSTNAME@` # Check if hostname is valid if test "$IN_RPM" -eq 0 -a $force -eq 0 From 542440e82318c65fc596bcdaa895dc6ba0698c46 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Aug 2003 17:45:42 +0300 Subject: [PATCH 088/282] after merge fix --- mysql-test/r/subselect.result | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index ae0383cff46..0fb5625854b 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -43,8 +43,8 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DEPENDENT SUBQUERY NULL NULL NULL NULL NULL NULL NULL No tables used 2 DERIVED NULL NULL NULL NULL NULL NULL NULL No tables used Warnings: -Note 1271 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 -Note 1271 Field or reference '.a' of SELECT #3 was resolved in SELECT #1 +Note 1273 Field or reference 'a' of SELECT #3 was resolved in SELECT #1 +Note 1273 Field or reference 'b.a' of SELECT #3 was resolved in SELECT #1 SELECT 1 FROM (SELECT 1 as a) as b HAVING (SELECT a)=1; 1 1 @@ -211,7 +211,7 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t2 ALL NULL NULL NULL NULL 2 3 DEPENDENT SUBQUERY t3 ALL NULL NULL NULL NULL 3 Using where Warnings: -Note 1271 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 +Note 1273 Field or reference 't4.a' of SELECT #3 was resolved in SELECT #1 select * from t3 where exists (select * from t2 where t2.b=t3.a); a 7 @@ -292,8 +292,8 @@ id select_type table type possible_keys key key_len ref rows Extra 2 DEPENDENT SUBQUERY t1 system NULL NULL NULL NULL 1 3 DEPENDENT UNION t5 ALL NULL NULL NULL NULL 2 Using where Warnings: -Note 1271 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 -Note 1271 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 +Note 1273 Field or reference 't2.a' of SELECT #2 was resolved in SELECT #1 +Note 1273 Field or reference 't2.a' of SELECT #3 was resolved in SELECT #1 select (select a from t1 where t1.a=t2.a union all select a from t5 where t5.a=t2.a), a from t2; ERROR 21000: Subselect returns more than 1 record create table t6 (patient_uq int, clinic_uq int, index i1 (clinic_uq)); @@ -310,7 +310,7 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t6 ALL NULL NULL NULL NULL 4 Using where 2 DEPENDENT SUBQUERY t7 eq_ref PRIMARY PRIMARY 4 test.t6.clinic_uq 1 Warnings: -Note 1271 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 +Note 1273 Field or reference 'clinic_uq' of SELECT #2 was resolved in SELECT #1 select * from t1 where a= (select a from t2,t4 where t2.b=t4.b); ERROR 23000: Column: 'a' in field list is ambiguous drop table if exists t1,t2,t3; From c01d65bce04c91c267ca851cd5a6d7b6fd796b97 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Aug 2003 17:52:54 +0300 Subject: [PATCH 089/282] Cleanups BTREE, HASH and RTREE are not reserved symbols anymore mysql-test/t/loaddata.test: Removed empty lines mysys/my_malloc.c: Fixed old style variable name mysys/my_realloc.c: Fixed old style variable name sql/sql_yacc.yy: BTREE, HASH and RTREE are not reserved symbols anymore sql/table.cc: Simple optimization --- mysql-test/t/loaddata.test | 4 ---- mysys/my_malloc.c | 34 +++++++++++++++++----------------- mysys/my_realloc.c | 33 +++++++++++++++++---------------- sql/sql_yacc.yy | 3 +++ sql/table.cc | 7 ++----- 5 files changed, 39 insertions(+), 42 deletions(-) diff --git a/mysql-test/t/loaddata.test b/mysql-test/t/loaddata.test index 2f484d30ff7..199da9c4a84 100644 --- a/mysql-test/t/loaddata.test +++ b/mysql-test/t/loaddata.test @@ -15,7 +15,3 @@ truncate table t1; load data infile '../../std_data/loaddata1.dat' into table t1 fields terminated by ',' LINES STARTING BY ',' (b,c,d); SELECT * from t1; drop table t1; - - - - diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index b273363aaf1..df9fe1f9bc4 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -24,26 +24,26 @@ /* My memory allocator */ -gptr my_malloc(unsigned int Size, myf MyFlags) +gptr my_malloc(unsigned int size, myf my_flags) { gptr point; DBUG_ENTER("my_malloc"); - DBUG_PRINT("my",("Size: %u MyFlags: %d",Size, MyFlags)); + DBUG_PRINT("my",("size: %u my_flags: %d",size, my_flags)); - if (!Size) - Size=1; /* Safety */ - if ((point = (char*)malloc(Size)) == NULL) + if (!size) + size=1; /* Safety */ + if ((point = (char*)malloc(size)) == NULL) { my_errno=errno; - if (MyFlags & MY_FAE) + if (my_flags & MY_FAE) error_handler_hook=fatal_error_handler_hook; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size); - if (MyFlags & MY_FAE) + if (my_flags & (MY_FAE+MY_WME)) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); + if (my_flags & MY_FAE) exit(1); } - else if (MyFlags & MY_ZEROFILL) - bzero(point,Size); + else if (my_flags & MY_ZEROFILL) + bzero(point,size); DBUG_PRINT("exit",("ptr: %lx",point)); DBUG_RETURN(point); } /* my_malloc */ @@ -64,29 +64,29 @@ void my_no_flags_free(gptr ptr) /* malloc and copy */ -gptr my_memdup(const byte *from, uint length, myf MyFlags) +gptr my_memdup(const byte *from, uint length, myf my_flags) { gptr ptr; - if ((ptr=my_malloc(length,MyFlags)) != 0) + if ((ptr=my_malloc(length,my_flags)) != 0) memcpy((byte*) ptr, (byte*) from,(size_t) length); return(ptr); } -char *my_strdup(const char *from, myf MyFlags) +char *my_strdup(const char *from, myf my_flags) { gptr ptr; uint length=(uint) strlen(from)+1; - if ((ptr=my_malloc(length,MyFlags)) != 0) + if ((ptr=my_malloc(length,my_flags)) != 0) memcpy((byte*) ptr, (byte*) from,(size_t) length); return((my_string) ptr); } -char *my_strdup_with_length(const byte *from, uint length, myf MyFlags) +char *my_strdup_with_length(const byte *from, uint length, myf my_flags) { gptr ptr; - if ((ptr=my_malloc(length+1,MyFlags)) != 0) + if ((ptr=my_malloc(length+1,my_flags)) != 0) { memcpy((byte*) ptr, (byte*) from,(size_t) length); ((char*) ptr)[length]=0; diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c index 49d96c2eb4f..5190fa75dce 100644 --- a/mysys/my_realloc.c +++ b/mysys/my_realloc.c @@ -23,40 +23,41 @@ /* My memory re allocator */ -gptr my_realloc(gptr oldpoint, uint Size, myf MyFlags) +gptr my_realloc(gptr oldpoint, uint size, myf my_flags) { gptr point; DBUG_ENTER("my_realloc"); - DBUG_PRINT("my",("ptr: %lx Size: %u MyFlags: %d",oldpoint, Size, MyFlags)); + DBUG_PRINT("my",("ptr: %lx size: %u my_flags: %d",oldpoint, size, + my_flags)); - if (!oldpoint && (MyFlags & MY_ALLOW_ZERO_PTR)) - DBUG_RETURN(my_malloc(Size,MyFlags)); + if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR)) + DBUG_RETURN(my_malloc(size,my_flags)); #ifdef USE_HALLOC - if (!(point = malloc(Size))) + if (!(point = malloc(size))) { - if (MyFlags & MY_FREE_ON_ERROR) - my_free(oldpoint,MyFlags); - if (MyFlags & MY_HOLD_ON_ERROR) + if (my_flags & MY_FREE_ON_ERROR) + my_free(oldpoint,my_flags); + if (my_flags & MY_HOLD_ON_ERROR) DBUG_RETURN(oldpoint); my_errno=errno; - if (MyFlags & MY_FAE+MY_WME) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),Size); + if (my_flags & MY_FAE+MY_WME) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); } else { - memcpy(point,oldpoint,Size); + memcpy(point,oldpoint,size); free(oldpoint); } #else - if ((point = (char*)realloc(oldpoint,Size)) == NULL) + if ((point = (char*)realloc(oldpoint,size)) == NULL) { - if (MyFlags & MY_FREE_ON_ERROR) + if (my_flags & MY_FREE_ON_ERROR) my_free(oldpoint,MyFLAGS); - if (MyFlags & MY_HOLD_ON_ERROR) + if (my_flags & MY_HOLD_ON_ERROR) DBUG_RETURN(oldpoint); my_errno=errno; - if (MyFlags & (MY_FAE+MY_WME)) - my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), Size); + if (my_flags & (MY_FAE+MY_WME)) + my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG), size); } #endif DBUG_PRINT("exit",("ptr: %lx",point)); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 98746410470..2e66bcbb7aa 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4363,6 +4363,7 @@ keyword: | BOOL_SYM {} | BOOLEAN_SYM {} | BYTE_SYM {} + | BTREE_SYM {} | CACHE_SYM {} | CHANGED {} | CHARSET {} @@ -4408,6 +4409,7 @@ keyword: | GRANTS {} | GLOBAL_SYM {} | HANDLER_SYM {} + | HASH_SYM {} | HEAP_SYM {} | HELP_SYM {} | HOSTS_SYM {} @@ -4490,6 +4492,7 @@ keyword: | ROWS_SYM {} | ROW_FORMAT_SYM {} | ROW_SYM {} + | RTREE_SYM {} | SAVEPOINT_SYM {} | SECOND_SYM {} | SERIAL_SYM {} diff --git a/sql/table.cc b/sql/table.cc index 9d12de1f6c7..a980e086d60 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -1207,17 +1207,14 @@ bool get_field(MEM_ROOT *mem, Field *field, String *res) char *get_field(MEM_ROOT *mem, Field *field) { - char buff[MAX_FIELD_WIDTH], *to; + char buff[MAX_FIELD_WIDTH]; String str(buff,sizeof(buff),&my_charset_bin); uint length; field->val_str(&str,&str); if (!(length= str.length())) return NullS; - to= (char*) alloc_root(mem,length+1); - memcpy(to, str.ptr(), (uint) length); - to[length]=0; - return to; + return strmake_root(mem, str.ptr(), length); } From 91dc31d38334cddc0b47c9ac0c0be338fc8cfd20 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Aug 2003 20:23:48 +0300 Subject: [PATCH 090/282] Fix for bug in ROLLUP when all tables where 'const' tables (Bug #714) mysql-test/r/olap.result: new test case for bug mysql-test/t/olap.test: new test case for bug sql-common/client.c: Safety fix --- mysql-test/r/olap.result | 15 +++++++++++++++ mysql-test/t/olap.test | 11 +++++++++++ sql-common/client.c | 2 +- sql/sql_select.cc | 25 +++++++++++++++---------- 4 files changed, 42 insertions(+), 11 deletions(-) diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index 0b7a98e3fb3..84e37bf56a9 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -254,3 +254,18 @@ ERROR 42000: This version of MySQL doesn't yet support 'CUBE' select product, country_id , year, sum(profit) from t1 group by product, country_id, year with cube union all select product, country_id , year, sum(profit) from t1 group by product, country_id, year with rollup; ERROR 42000: This version of MySQL doesn't yet support 'CUBE' drop table t1,t2; +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES(100); +CREATE TABLE t2 (i int); +INSERT INTO t2 VALUES (100),(200); +SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP; +i COUNT(*) +100 1 +NULL 1 +SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP; +i i COUNT(*) +100 100 1 +100 200 1 +100 NULL 2 +NULL NULL 2 +drop table t1,t2; diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 3b1e3fac7c2..17bf6230f76 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -77,3 +77,14 @@ select product, country_id , year, sum(profit) from t1 group by product, country drop table t1,t2; +# +# Test bug with const tables +# + +CREATE TABLE t1 (i int); +INSERT INTO t1 VALUES(100); +CREATE TABLE t2 (i int); +INSERT INTO t2 VALUES (100),(200); +SELECT i, COUNT(*) FROM t1 GROUP BY i WITH ROLLUP; +SELECT t1.i, t2.i, COUNT(*) FROM t1,t2 GROUP BY t1.i,t2.i WITH ROLLUP; +drop table t1,t2; diff --git a/sql-common/client.c b/sql-common/client.c index 222f0bf0288..25b18c27d8a 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -587,7 +587,7 @@ net_safe_read(MYSQL *mysql) DBUG_PRINT("error",("Wrong connection or packet. fd: %s len: %d", vio_description(net->vio),len)); #ifdef MYSQL_SERVER - if (socket_errno == SOCKET_EINTR) + if (vio_errno(net->vio) == SOCKET_EINTR) return (packet_error); #endif /*MYSQL_SERVER*/ end_server(mysql); diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 15d6b3954ff..412e891bad1 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -117,10 +117,8 @@ static Item* part_of_refkey(TABLE *form,Field *field); static uint find_shortest_key(TABLE *table, key_map usable_keys); static bool test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order, ha_rows select_limit, bool no_changes); -static int create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order, +static int create_sort_index(THD *thd, JOIN *join, ORDER *order, ha_rows filesort_limit, ha_rows select_limit); -static int create_sort_index(THD *thd, JOIN_TAB *tab,ORDER *order, - ha_rows select_limit); static int remove_duplicates(JOIN *join,TABLE *entry,List &fields, Item *having); static int remove_dup_with_compare(THD *thd, TABLE *entry, Field **field, @@ -916,7 +914,7 @@ JOIN::optimize() { DBUG_PRINT("info",("Sorting for group")); thd->proc_info="Sorting for group"; - if (create_sort_index(thd, &join_tab[const_tables], group_list, + if (create_sort_index(thd, this, group_list, HA_POS_ERROR, HA_POS_ERROR) || alloc_group_fields(this, group_list) || make_sum_func_list(all_fields, fields_list, 1)) @@ -931,7 +929,7 @@ JOIN::optimize() { DBUG_PRINT("info",("Sorting for order")); thd->proc_info="Sorting for order"; - if (create_sort_index(thd, &join_tab[const_tables], order, + if (create_sort_index(thd, this, order, HA_POS_ERROR, HA_POS_ERROR)) DBUG_RETURN(1); order=0; @@ -1235,7 +1233,7 @@ JOIN::exec() if (curr_join->group_list) { thd->proc_info= "Creating sort index"; - if (create_sort_index(thd, curr_join->join_tab, curr_join->group_list, + if (create_sort_index(thd, curr_join, curr_join->group_list, HA_POS_ERROR, HA_POS_ERROR) || make_group_fields(this, curr_join)) { @@ -1416,7 +1414,7 @@ JOIN::exec() } } } - if (create_sort_index(thd, &curr_join->join_tab[curr_join->const_tables], + if (create_sort_index(thd, curr_join, curr_join->group_list ? curr_join->group_list : curr_join->order, curr_join->select_limit, unit->select_limit_cnt)) @@ -6770,16 +6768,23 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit, */ static int -create_sort_index(THD *thd, JOIN_TAB *tab, ORDER *order, +create_sort_index(THD *thd, JOIN *join, ORDER *order, ha_rows filesort_limit, ha_rows select_limit) { SORT_FIELD *sortorder; uint length; ha_rows examined_rows; - TABLE *table=tab->table; - SQL_SELECT *select=tab->select; + TABLE *table; + SQL_SELECT *select; + JOIN_TAB *tab; DBUG_ENTER("create_sort_index"); + if (join->tables == join->const_tables) + DBUG_RETURN(0); // One row, no need to sort + tab= join->join_tab + join->const_tables; + table= tab->table; + select= tab->select; + if (test_if_skip_sort_order(tab,order,select_limit,0)) DBUG_RETURN(0); if (!(sortorder=make_unireg_sortorder(order,&length))) From 70631cff85742bfd8e8deb4e174eb6e74f017800 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Aug 2003 22:02:58 +0300 Subject: [PATCH 091/282] Fixed a very rarge memory overrun bug in the myisamlog program. --- myisam/myisamlog.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/myisam/myisamlog.c b/myisam/myisamlog.c index ceca8d2a0e3..091f9ad1d7e 100644 --- a/myisam/myisamlog.c +++ b/myisam/myisamlog.c @@ -413,8 +413,16 @@ static int examine_log(my_string file_name, char **table_names) VOID(tree_walk(&tree,(tree_walk_action) test_if_open,(void*) &open_param, left_root_right)); file_info.id=open_param.max_id+1; + /* + * In the line below +10 is added to accomodate '<' and '>' chars + * plus '\0' at the end, so that there is place for 7 digits. + * It is improbable that same table can have that many entries in + * the table cache. + * The additional space is needed for the sprintf commands two lines + * below. + */ file_info.show_name=my_memdup(isam_file_name, - (uint) strlen(isam_file_name)+6, + (uint) strlen(isam_file_name)+10, MYF(MY_WME)); if (file_info.id > 1) sprintf(strend(file_info.show_name),"<%d>",file_info.id); From cc7b3c8269a761a848c26f2c6365a8cd5636f97a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 26 Aug 2003 23:52:15 +0200 Subject: [PATCH 092/282] fix ANALYZE TBALE to never generate rec_per_key_part < 1, as it prevent the table from being marked as analyzed (and the value is meaningless anyway) --- myisam/mi_check.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 0d7d7fae628..735c54c4cf6 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -36,7 +36,7 @@ /* Functions defined in this file */ static int check_k_link(MI_CHECK *param, MI_INFO *info,uint nr); -static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, +static int chk_index(MI_CHECK *param, MI_INFO *info,MI_KEYDEF *keyinfo, my_off_t page, uchar *buff, ha_rows *keys, ha_checksum *key_checksum, uint level); static uint isam_key_length(MI_INFO *info,MI_KEYDEF *keyinfo); @@ -3681,6 +3681,9 @@ void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part, tmp=records; else tmp= (records + (count+1)/2) / (count+1); + /* for some weird keys (e.g. FULLTEXT) tmp can be <1 here. + let's ensure it is not */ + set_if_bigger(tmp,1); if (tmp >= (ulonglong) ~(ulong) 0) tmp=(ulonglong) ~(ulong) 0; *rec_per_key_part=(ulong) tmp; From d1be872edf3978ae2ca143392e3a9d9725117f2b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 00:58:42 +0200 Subject: [PATCH 093/282] do not try to "analyze" or "sort index" in the table that has no indexes or no records if --check-only-changed option is used. It's because such a table is never marked as "analyzed" or "sorted", so --check-only-changed doesn't work --- myisam/myisamchk.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/myisam/myisamchk.c b/myisam/myisamchk.c index a41292aeb04..83edadf153f 100644 --- a/myisam/myisamchk.c +++ b/myisam/myisamchk.c @@ -794,15 +794,18 @@ static int myisamchk(MI_CHECK *param, my_string filename) !(param->testflag & T_CHECK_ONLY_CHANGED)))) need_to_check=1; - if ((param->testflag & T_STATISTICS) && - (share->state.changed & STATE_NOT_ANALYZED)) - need_to_check=1; - if ((param->testflag & T_SORT_INDEX) && - (share->state.changed & STATE_NOT_SORTED_PAGES)) - need_to_check=1; - if ((param->testflag & T_REP_BY_SORT) && - (share->state.changed & STATE_NOT_OPTIMIZED_KEYS)) - need_to_check=1; + if (info->s->base.keys && info->state->records) + { + if ((param->testflag & T_STATISTICS) && + (share->state.changed & STATE_NOT_ANALYZED)) + need_to_check=1; + if ((param->testflag & T_SORT_INDEX) && + (share->state.changed & STATE_NOT_SORTED_PAGES)) + need_to_check=1; + if ((param->testflag & T_REP_BY_SORT) && + (share->state.changed & STATE_NOT_OPTIMIZED_KEYS)) + need_to_check=1; + } if ((param->testflag & T_CHECK_ONLY_CHANGED) && (share->state.changed & (STATE_CHANGED | STATE_CRASHED | STATE_CRASHED_ON_REPAIR))) From 59806e1004d205bae01673fe7ed9a60537112455 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 02:51:39 +0300 Subject: [PATCH 094/282] vio ssl structure renames (to get rid of ending _) Added TCP/IP read/write timeout for windows Check on windows if second server is started with same TCP/IP port BitKeeper/deleted/.del-have_openssl_2.inc~8c9f1a45676b698f: Delete: mysql-test/include/have_openssl_2.inc BitKeeper/deleted/.del-have_openssl_2.require~53bbdfc136fb514: Delete: mysql-test/r/have_openssl_2.require BitKeeper/deleted/.del-openssl_2.test~f2dfa927f19d14f8: Delete: mysql-test/t/openssl_2.test BitKeeper/etc/ignore: added libmysql/vio_priv.h libmysql_r/vio_priv.h client/mysql.cc: vio ssl structure renames include/violite.h: Cleanup violite.h interface (move things to vio_priv.h) libmysql/Makefile.am: Use vio_priv.h libmysql/Makefile.shared: Use vio_priv.h libmysqld/lib_vio.c: Added timeout for windows mysys/my_getopt.c: Indentaion cleanup sql/item_cmpfunc.cc: Remove compiler warnings sql/item_func.cc: Remove compiler warnings sql/mini_client.cc: vio ssl structure renames sql/mysqld.cc: Check on windows if second server is started with same TCP/IP port sql/net_serv.cc: Add read/write timeouts for windows sql/sql_acl.cc: vio ssl structure renames sql/sql_show.cc: vio ssl structure renames vio/vio.c: Added timeouts for windows vio/viosocket.c: Added timeouts for windows vio/viossl.c: Added timeouts for windows Cleaned up structure element names vio/viosslfactories.c: Added timeouts for windows Cleaned up structure element names --- .bzrignore | 2 + client/mysql.cc | 7 +- include/violite.h | 150 ++++++++------------------ libmysql/Makefile.am | 2 +- libmysql/Makefile.shared | 3 +- libmysqld/lib_vio.c | 5 + mysql-test/include/have_openssl_2.inc | 4 - mysql-test/r/have_openssl_2.require | 2 - mysql-test/t/openssl_2.test | 5 - mysys/my_getopt.c | 3 +- sql/item_cmpfunc.cc | 3 + sql/item_func.cc | 5 + sql/mini_client.cc | 2 +- sql/mysqld.cc | 13 +++ sql/net_serv.cc | 3 + sql/sql_acl.cc | 17 +-- sql/sql_show.cc | 61 +++++------ vio/vio.c | 10 +- vio/vio_priv.h | 54 ++++++++++ vio/viosocket.c | 25 +++-- vio/viossl.c | 89 +++++++-------- vio/viosslfactories.c | 65 +++++------ 22 files changed, 264 insertions(+), 266 deletions(-) delete mode 100644 mysql-test/include/have_openssl_2.inc delete mode 100644 mysql-test/r/have_openssl_2.require delete mode 100644 mysql-test/t/openssl_2.test create mode 100644 vio/vio_priv.h diff --git a/.bzrignore b/.bzrignore index 8514eb6ffb1..1e4c8ae88af 100644 --- a/.bzrignore +++ b/.bzrignore @@ -536,3 +536,5 @@ Docs/internals.pdf Docs/internals.txt Docs/internals_toc.html scripts/make_win_src_distribution +libmysql/vio_priv.h +libmysql_r/vio_priv.h diff --git a/client/mysql.cc b/client/mysql.cc index 4fe832a790e..d4a06b34d32 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -708,6 +708,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; case 'W': #ifdef __WIN__ + my_free(opt_mysql_unix_port, MYF(MY_ALLOW_ZERO_PTR)); opt_mysql_unix_port= my_strdup(MYSQL_NAMEDPIPE, MYF(0)); #endif break; @@ -2329,10 +2330,10 @@ com_status(String *buffer __attribute__((unused)), (void) mysql_fetch_row(result); // Read eof } #ifdef HAVE_OPENSSL - if (mysql.net.vio && mysql.net.vio->ssl_ && - SSL_get_cipher(mysql.net.vio->ssl_)) + if (mysql.net.vio && mysql.net.vio->ssl_arg && + SSL_get_cipher((SSL*) mysql.net.vio->ssl_arg)) tee_fprintf(stdout, "SSL:\t\t\tCipher in use is %s\n", - SSL_get_cipher(mysql.net.vio->ssl_)); + SSL_get_cipher((SSL*) mysql.net.vio->ssl_arg)); else #endif /* HAVE_OPENSSL */ tee_puts("SSL:\t\t\tNot in use", stdout); diff --git a/include/violite.h b/include/violite.h index d20fab23239..18f862d4b77 100644 --- a/include/violite.h +++ b/include/violite.h @@ -43,6 +43,7 @@ Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost); Vio* vio_new_win32pipe(HANDLE hPipe); #endif void vio_delete(Vio* vio); +int vio_close(Vio* vio); #ifdef EMBEDDED_LIBRARY void vio_reset(Vio *vio); @@ -51,57 +52,64 @@ void vio_reset(Vio* vio, enum enum_vio_type type, my_socket sd, HANDLE hPipe, my_bool localhost); #endif -/* - * vio_read and vio_write should have the same semantics - * as read(2) and write(2). - */ int vio_read(Vio *vio, gptr buf, int size); int vio_write(Vio *vio, const gptr buf, int size); -/* - * Whenever the socket is set to blocking mode or not. - */ int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode); my_bool vio_is_blocking(Vio *vio); -/* - * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. - */ +/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */ int vio_fastsend(Vio *vio); -/* - * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. - */ +/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible */ int vio_keepalive(Vio *vio, my_bool onoff); -/* - * Whenever we should retry the last read/write operation. - */ +/* Whenever we should retry the last read/write operation. */ my_bool vio_should_retry(Vio *vio); -/* - * When the workday is over... - */ -int vio_close(Vio* vio); -/* - * Short text description of the socket for those, who are curious.. - */ +/* Short text description of the socket for those, who are curious.. */ const char* vio_description(Vio *vio); - /* Return the type of the connection */ enum enum_vio_type vio_type(Vio* vio); - /* Return last error number */ int vio_errno(Vio*vio); - /* Get socket number */ my_socket vio_fd(Vio*vio); - -/* - * Remote peer's address and name in text form. - */ +/* Remote peer's address and name in text form */ my_bool vio_peer_addr(Vio* vio, char *buf, uint16 *port); - /* Remotes in_addr */ - void vio_in_addr(Vio *vio, struct in_addr *in); - my_bool vio_poll_read(Vio *vio,uint timeout); +void vio_timeout(Vio *vio,uint timeout); + +#ifdef HAVE_OPENSSL +#define HEADER_DES_LOCL_H dummy_something +#include +#include + +struct st_VioSSLAcceptorFd +{ + SSL_CTX *ssl_context; + SSL_METHOD *ssl_method; + struct st_VioSSLAcceptorFd *session_id_context; +}; + +/* One copy for client */ +struct st_VioSSLConnectorFd +{ + SSL_CTX *ssl_context; + /* function pointers which are only once for SSL client */ + SSL_METHOD *ssl_method; +}; + +int sslaccept(struct st_VioSSLAcceptorFd*, Vio *, long timeout); +int sslconnect(struct st_VioSSLConnectorFd*, Vio *, long timeout); + +struct st_VioSSLConnectorFd +*new_VioSSLConnectorFd(const char *key_file, const char *cert_file, + const char *ca_file, const char *ca_path, + const char *cipher); +struct st_VioSSLAcceptorFd +*new_VioSSLAcceptorFd(const char *key_file, const char *cert_file, + const char *ca_file,const char *ca_path, + const char *cipher); +Vio *new_VioSSL(struct st_VioSSLAcceptorFd *fd, Vio *sd, int state); +#endif #ifdef __cplusplus } @@ -121,77 +129,9 @@ my_bool vio_poll_read(Vio *vio,uint timeout); #define vio_close(vio) ((vio)->vioclose)(vio) #define vio_peer_addr(vio, buf, prt) (vio)->peer_addr(vio, buf, prt) #define vio_in_addr(vio, in) (vio)->in_addr(vio, in) +#define vio_timeout(vio, seconds) (vio)->timeout(vio, seconds) #endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */ -#ifdef HAVE_OPENSSL -#define HEADER_DES_LOCL_H dummy_something -#include -#include -#include "my_net.h" /* needed because of struct in_addr */ - -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -void vio_ssl_delete(Vio* vio); - -int vio_ssl_read(Vio* vio,gptr buf, int size); -int vio_ssl_write(Vio* vio,const gptr buf,int size); - -/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ - int vio_ssl_fastsend(Vio* vio); -/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ -int vio_ssl_keepalive(Vio* vio, my_bool onoff); -/* Whenever we should retry the last read/write operation. */ -my_bool vio_ssl_should_retry(Vio* vio); -/* When the workday is over... */ -int vio_ssl_close(Vio* vio); -/* Return last error number */ -int vio_ssl_errno(Vio *vio); -my_bool vio_ssl_peer_addr(Vio* vio, char *buf, uint16 *port); -void vio_ssl_in_addr(Vio *vio, struct in_addr *in); -int vio_ssl_blocking(Vio * vio, my_bool set_blocking_mode, my_bool *old_mode); - -/* Single copy for server */ -enum vio_ssl_acceptorfd_state -{ - state_connect = 1, - state_accept = 2 -}; - -struct st_VioSSLAcceptorFd -{ - SSL_CTX* ssl_context_; - SSL_METHOD* ssl_method_; - struct st_VioSSLAcceptorFd* session_id_context_; -}; - -/* One copy for client */ -struct st_VioSSLConnectorFd -{ - SSL_CTX* ssl_context_; - /* function pointers which are only once for SSL client */ - SSL_METHOD* ssl_method_; -}; - -int sslaccept(struct st_VioSSLAcceptorFd*, Vio*, long timeout); -int sslconnect(struct st_VioSSLConnectorFd*, Vio*, long timeout); - -struct st_VioSSLConnectorFd -*new_VioSSLConnectorFd(const char* key_file, const char* cert_file, - const char* ca_file, const char* ca_path, - const char* cipher); -struct st_VioSSLAcceptorFd -*new_VioSSLAcceptorFd(const char* key_file, const char* cert_file, - const char* ca_file,const char* ca_path, - const char* cipher); -Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state); - -#ifdef __cplusplus -} -#endif -#endif /* HAVE_OPENSSL */ - /* This enumerator is used in parser - should be always visible */ enum SSL_type { @@ -228,10 +168,8 @@ struct st_vio void (*in_addr)(Vio*, struct in_addr*); my_bool (*should_retry)(Vio*); int (*vioclose)(Vio*); - -#ifdef HAVE_OPENSSL - SSL* ssl_; -#endif /* HAVE_OPENSSL */ + void (*timeout)(Vio*, unsigned int timeout); + void *ssl_arg; #endif /* HAVE_VIO */ }; #endif /* EMBEDDED_LIBRARY */ diff --git a/libmysql/Makefile.am b/libmysql/Makefile.am index c767771c93f..686f7807949 100644 --- a/libmysql/Makefile.am +++ b/libmysql/Makefile.am @@ -41,7 +41,7 @@ link_sources: rm -f $(srcdir)/$$f; \ @LN_CP_F@ $(srcdir)/../strings/$$f $(srcdir)/$$f; \ done; \ - for f in $$vs; do \ + for f in $$vs $(vioheaders); do \ rm -f $(srcdir)/$$f; \ @LN_CP_F@ $(srcdir)/../vio/$$f $(srcdir)/$$f; \ done; \ diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 9f4b3e9ccdd..764983506d1 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -46,6 +46,7 @@ mystringsextra= strto.c mystringsgen= ctype_autoconf.c dbugobjects = dbug.lo # IT IS IN SAFEMALLOC.C sanity.lo mysysheaders = mysys_priv.h my_static.h +vioheaders = vio_priv.h mysysobjects1 = my_init.lo my_static.lo my_malloc.lo my_realloc.lo \ my_create.lo my_delete.lo mf_tempfile.lo my_open.lo \ mf_casecnv.lo my_read.lo my_write.lo errors.lo \ @@ -86,7 +87,7 @@ clean-local: `echo $(mysysobjects) | sed "s;\.lo;.c;g"` \ `echo $(vio_objects) | sed "s;\.lo;.c;g"` \ $(CHARSET_SRCS) $(CHARSET_OBJS) \ - $(mystringsextra) $(mystringsgen) $(mysysheaders) \ + $(mystringsextra) $(mystringsgen) $(mysysheaders) $(vioheaders)\ ctype_extra_sources.c net.c ../linked_client_sources ctype_extra_sources.c: conf_to_src diff --git a/libmysqld/lib_vio.c b/libmysqld/lib_vio.c index 448c11f9abd..ccad6ac8b7e 100644 --- a/libmysqld/lib_vio.c +++ b/libmysqld/lib_vio.c @@ -218,4 +218,9 @@ my_bool vio_poll_read(Vio *vio,uint timeout) return 0; } + +void vio_timeout(Vio *vio __attribute__((unused)), + uint timeout __attribute__((unused))) +{ +} #endif /* HAVE_VIO */ diff --git a/mysql-test/include/have_openssl_2.inc b/mysql-test/include/have_openssl_2.inc deleted file mode 100644 index 724d295a398..00000000000 --- a/mysql-test/include/have_openssl_2.inc +++ /dev/null @@ -1,4 +0,0 @@ --- require r/have_openssl_2.require -disable_query_log; -SHOW STATUS LIKE "SSL_get_cipher"; -enable_query_log; diff --git a/mysql-test/r/have_openssl_2.require b/mysql-test/r/have_openssl_2.require deleted file mode 100644 index 09a65d7d9bc..00000000000 --- a/mysql-test/r/have_openssl_2.require +++ /dev/null @@ -1,2 +0,0 @@ -Variable_name Value -jkhjkhfs diff --git a/mysql-test/t/openssl_2.test b/mysql-test/t/openssl_2.test deleted file mode 100644 index 12f1240f3af..00000000000 --- a/mysql-test/t/openssl_2.test +++ /dev/null @@ -1,5 +0,0 @@ -# We want to test everything with SSL turned on. --- source include/have_openssl_2.inc - -SHOW STATUS LIKE 'SSL%'; - diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index e18c5a0b9eb..5644d81837d 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -464,8 +464,7 @@ static int setval(const struct my_option *opts, char *argument, break; case GET_STR_ALLOC: if ((*((char**) result_pos))) - my_free((*(char**) result_pos), - MYF(MY_WME | MY_FAE)); + my_free((*(char**) result_pos), MYF(MY_WME | MY_FAE)); if (!(*((char**) result_pos)= my_strdup(argument, MYF(MY_WME)))) return EXIT_OUT_OF_MEMORY; break; diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 04c27de63eb..b940064923f 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1177,7 +1177,10 @@ Item_cond::fix_fields(THD *thd,TABLE_LIST *tables) { List_iterator li(list); Item *item; +#ifndef EMBEDDED_LIBRARY // Avoid compiler warning char buff[sizeof(char*)]; // Max local vars in function +#endif + not_null_tables_cache= used_tables_cache= 0; const_item_cache= 0; /* diff --git a/sql/item_func.cc b/sql/item_func.cc index 8e9677cc459..be5d98f20ec 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -59,7 +59,10 @@ bool Item_func::fix_fields(THD *thd,TABLE_LIST *tables) { Item **arg,**arg_end; +#ifndef EMBEDDED_LIBRARY // Avoid compiler warning char buff[STACK_BUFF_ALLOC]; // Max argument in function +#endif + binary=0; used_tables_cache= not_null_tables_cache= 0; const_item_cache=1; @@ -1159,7 +1162,9 @@ bool udf_handler::fix_fields(THD *thd,TABLE_LIST *tables,Item_result_field *func, uint arg_count, Item **arguments) { +#ifndef EMBEDDED_LIBRARY // Avoid compiler warning char buff[STACK_BUFF_ALLOC]; // Max argument in function +#endif DBUG_ENTER("Item_udf_func::fix_fields"); if (thd) diff --git a/sql/mini_client.cc b/sql/mini_client.cc index a8a0c639abd..9993951d8e9 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -843,7 +843,7 @@ mc_mysql_connect(MYSQL *mysql,const char *host, const char *user, } /* Do the SSL layering. */ DBUG_PRINT("info", ("IO layer change in progress...")); - DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context_)); + DBUG_PRINT("info", ("IO context %p",((struct st_VioSSLConnectorFd*)mysql->connector_fd)->ssl_context)); sslconnect((struct st_VioSSLConnectorFd*)(mysql->connector_fd),mysql->net.vio, (long)(mysql->options.connect_timeout)); DBUG_PRINT("info", ("IO layer change done!")); } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index eaecb6e1aa3..10d7955f13b 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1136,7 +1136,14 @@ static void server_init(void) IPaddr.sin_family = AF_INET; IPaddr.sin_addr.s_addr = my_bind_addr; IPaddr.sin_port = (unsigned short) htons((unsigned short) mysql_port); + +#ifndef __WIN__ + /* + We should not use SO_REUSEADDR on windows as this would enable a + user to open two mysqld servers with the same TCP/IP port. + */ (void) setsockopt(ip_sock,SOL_SOCKET,SO_REUSEADDR,(char*)&arg,sizeof(arg)); +#endif if (bind(ip_sock, my_reinterpret_cast(struct sockaddr *) (&IPaddr), sizeof(IPaddr)) < 0) { @@ -3011,6 +3018,12 @@ extern "C" pthread_handler_decl(handle_connections_sockets, } if (sock == unix_sock) thd->host=(char*) localhost; +#ifdef __WIN__ + /* Set default wait_timeout */ + ulong wait_timeout= global_system_variables.net_wait_timeout * 1000; + (void) setsockopt(new_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&wait_timeout, + sizeof(wait_timeout)); +#endif create_new_thread(thd); } diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 8f0d659daf2..18dadf24efa 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -434,6 +434,7 @@ net_real_write(NET *net,const char *packet,ulong len) thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff); #else alarmed=0; + vio_timeout(net->vio, net->write_timeout); #endif /* NO_ALARM */ pos=(char*) packet; end=pos+len; @@ -623,6 +624,8 @@ my_real_read(NET *net, ulong *complen) #ifndef NO_ALARM if (net_blocking) thr_alarm(&alarmed,net->read_timeout,&alarm_buff); +#else + vio_timeout(net->vio, net->read_timeout); #endif /* NO_ALARM */ pos = net->buff + net->where_b; /* net->packet -4 */ diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 9f3068fce85..3b5e9983b80 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -531,6 +531,9 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, (my_bool) old_ver))) { Vio *vio=thd->net.vio; +#ifdef HAVE_OPENSSL + SSL *ssl= (SSL*) vio->ssl_arg; +#endif /* In this point we know that user is allowed to connect from given host by given username/password pair. Now @@ -553,8 +556,8 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, we should reject connection. */ if (vio_type(vio) == VIO_TYPE_SSL && - SSL_get_verify_result(vio->ssl_) == X509_V_OK && - SSL_get_peer_certificate(vio->ssl_)) + SSL_get_verify_result(ssl) == X509_V_OK && + SSL_get_peer_certificate(ssl)) user_access=acl_user->access; break; case SSL_TYPE_SPECIFIED: /* Client should have specified attrib */ @@ -563,28 +566,28 @@ ulong acl_getroot(THD *thd, const char *host, const char *ip, const char *user, we should reject connection. */ if (vio_type(vio) == VIO_TYPE_SSL && - SSL_get_verify_result(vio->ssl_) == X509_V_OK) + SSL_get_verify_result(ssl) == X509_V_OK) { if (acl_user->ssl_cipher) { DBUG_PRINT("info",("comparing ciphers: '%s' and '%s'", acl_user->ssl_cipher, - SSL_get_cipher(vio->ssl_))); - if (!strcmp(acl_user->ssl_cipher,SSL_get_cipher(vio->ssl_))) + SSL_get_cipher(ssl))); + if (!strcmp(acl_user->ssl_cipher,SSL_get_cipher(ssl))) user_access=acl_user->access; else { if (global_system_variables.log_warnings) sql_print_error("X509 ciphers mismatch: should be '%s' but is '%s'", acl_user->ssl_cipher, - SSL_get_cipher(vio->ssl_)); + SSL_get_cipher(ssl)); user_access=NO_ACCESS; break; } } /* Prepare certificate (if exists) */ DBUG_PRINT("info",("checkpoint 1")); - X509* cert=SSL_get_peer_certificate(vio->ssl_); + X509* cert=SSL_get_peer_certificate(ssl); DBUG_PRINT("info",("checkpoint 2")); /* If X509 issuer is speified, we check it... */ if (acl_user->x509_issuer) diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 6680485ef0c..a7de04d0bfa 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1274,77 +1274,77 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, case SHOW_SSL_CTX_SESS_ACCEPT: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_accept(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_accept(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_ACCEPT_GOOD: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_accept_good(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_accept_good(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_CONNECT_GOOD: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_connect_good(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_connect_good(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_ACCEPT_RENEGOTIATE: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_accept_renegotiate(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_accept_renegotiate(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_CONNECT_RENEGOTIATE: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_connect_renegotiate(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_connect_renegotiate(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_CB_HITS: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_cb_hits(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_cb_hits(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_HITS: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_hits(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_hits(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_CACHE_FULL: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_cache_full(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_cache_full(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_MISSES: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_misses(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_misses(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_TIMEOUTS: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_timeouts(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_timeouts(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_NUMBER: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_number(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_number(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_CONNECT: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_connect(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_connect(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_SESS_GET_CACHE_SIZE: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_sess_get_cache_size(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_sess_get_cache_size(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_GET_VERIFY_MODE: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_get_verify_mode(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_get_verify_mode(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_GET_VERIFY_DEPTH: net_store_data(&packet2,(uint32) (!ssl_acceptor_fd ? 0 : - SSL_CTX_get_verify_depth(ssl_acceptor_fd->ssl_context_))); + SSL_CTX_get_verify_depth(ssl_acceptor_fd->ssl_context))); break; case SHOW_SSL_CTX_GET_SESSION_CACHE_MODE: if (!ssl_acceptor_fd) @@ -1352,7 +1352,7 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, net_store_data(&packet2,"NONE" ); break; } - switch (SSL_CTX_get_session_cache_mode(ssl_acceptor_fd->ssl_context_)) + switch (SSL_CTX_get_session_cache_mode(ssl_acceptor_fd->ssl_context)) { case SSL_SESS_CACHE_OFF: net_store_data(&packet2,"OFF" ); @@ -1379,37 +1379,38 @@ int mysqld_show(THD *thd, const char *wild, show_var_st *variables, break; /* First group - functions relying on SSL */ case SHOW_SSL_GET_VERSION: - net_store_data(&packet2, thd->net.vio->ssl_ ? - SSL_get_version(thd->net.vio->ssl_) : ""); + net_store_data(&packet2, thd->net.vio->ssl_arg ? + SSL_get_version((SSL*) thd->net.vio->ssl_arg) : ""); break; case SHOW_SSL_SESSION_REUSED: - net_store_data(&packet2,(uint32) (thd->net.vio->ssl_ ? - SSL_session_reused(thd->net.vio->ssl_) : 0)); + net_store_data(&packet2,(uint32) (thd->net.vio->ssl_arg ? + SSL_session_reused((SSL*) thd->net.vio->ssl_arg) : 0)); break; case SHOW_SSL_GET_DEFAULT_TIMEOUT: - net_store_data(&packet2,(uint32) (thd->net.vio->ssl_ ? - SSL_get_default_timeout(thd->net.vio->ssl_):0)); + net_store_data(&packet2,(uint32) (thd->net.vio->ssl_arg ? + SSL_get_default_timeout((SSL*) thd->net.vio->ssl_arg) : + 0)); break; case SHOW_SSL_GET_VERIFY_MODE: - net_store_data(&packet2,(uint32) (thd->net.vio->ssl_ ? - SSL_get_verify_mode(thd->net.vio->ssl_):0)); + net_store_data(&packet2,(uint32) (thd->net.vio->ssl_arg ? + SSL_get_verify_mode((SSL*) thd->net.vio->ssl_arg):0)); break; case SHOW_SSL_GET_VERIFY_DEPTH: - net_store_data(&packet2,(uint32) (thd->net.vio->ssl_ ? - SSL_get_verify_depth(thd->net.vio->ssl_):0)); + net_store_data(&packet2,(uint32) (thd->net.vio->ssl_arg ? + SSL_get_verify_depth((SSL*) thd->net.vio->ssl_arg):0)); break; case SHOW_SSL_GET_CIPHER: - net_store_data(&packet2, thd->net.vio->ssl_ ? - SSL_get_cipher(thd->net.vio->ssl_) : ""); + net_store_data(&packet2, thd->net.vio->ssl_arg ? + SSL_get_cipher((SSL*) thd->net.vio->ssl_arg) : ""); break; case SHOW_SSL_GET_CIPHER_LIST: - if (thd->net.vio->ssl_) + if (thd->net.vio->ssl_arg) { char buf[1024], *pos; pos=buf; for (int i=0 ; i++ ;) { - const char *p=SSL_get_cipher_list(thd->net.vio->ssl_,i); + const char *p=SSL_get_cipher_list((SSL*) thd->net.vio->ssl_arg,i); if (p == NULL) break; pos=strmov(pos, p); diff --git a/vio/vio.c b/vio/vio.c index d822651cca6..2b745ab3ec6 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -21,13 +21,7 @@ the file descriptior. */ -#define DONT_MAP_VIO -#include -#include -#include -#include -#include -#include +#include "vio_priv.h" /* * Helper to fill most of the Vio* with defaults. @@ -61,6 +55,7 @@ void vio_reset(Vio* vio, enum enum_vio_type type, vio->in_addr =vio_ssl_in_addr; vio->vioblocking =vio_ssl_blocking; vio->is_blocking =vio_is_blocking; + vio->timeout =vio_ssl_timeout; } else /* default is VIO_TYPE_TCPIP */ #endif /* HAVE_OPENSSL */ @@ -77,6 +72,7 @@ void vio_reset(Vio* vio, enum enum_vio_type type, vio->in_addr =vio_in_addr; vio->vioblocking =vio_blocking; vio->is_blocking =vio_is_blocking; + vio->timeout =vio_timeout; } #endif /* HAVE_VIO */ DBUG_VOID_RETURN; diff --git a/vio/vio_priv.h b/vio/vio_priv.h new file mode 100644 index 00000000000..66a9bde4e0d --- /dev/null +++ b/vio/vio_priv.h @@ -0,0 +1,54 @@ +/* Copyright (C) 2003 MySQL 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 */ + +/* Structures and functions private to the vio package */ + +#define DONT_MAP_VIO +#include +#include +#include +#include +#include + +#ifdef HAVE_OPENSSL +#include "my_net.h" /* needed because of struct in_addr */ + +void vio_ssl_delete(Vio* vio); +int vio_ssl_read(Vio *vio,gptr buf, int size); +int vio_ssl_write(Vio *vio,const gptr buf,int size); +void vio_ssl_timeout(Vio *vio, uint timeout); + +/* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ +int vio_ssl_fastsend(Vio *vio); +/* setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ +int vio_ssl_keepalive(Vio *vio, my_bool onoff); +/* Whenever we should retry the last read/write operation. */ +my_bool vio_ssl_should_retry(Vio *vio); +/* When the workday is over... */ +int vio_ssl_close(Vio *vio); +/* Return last error number */ +int vio_ssl_errno(Vio *vio); +my_bool vio_ssl_peer_addr(Vio *vio, char *buf, uint16 *port); +void vio_ssl_in_addr(Vio *vio, struct in_addr *in); +int vio_ssl_blocking(Vio *vio, my_bool set_blocking_mode, my_bool *old_mode); + +/* Single copy for server */ +enum vio_ssl_acceptorfd_state +{ + state_connect = 1, + state_accept = 2 +}; +#endif /* HAVE_OPENSSL */ diff --git a/vio/viosocket.c b/vio/viosocket.c index 6f5c4142a45..ad156fc33bf 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -21,19 +21,7 @@ the file descriptior. */ -#define DONT_MAP_VIO -#include -#include - -#include -#include -#include -#include -#include - -#ifndef __WIN__ -#define HANDLE void * -#endif +#include "vio_priv.h" void vio_delete(Vio* vio) { @@ -334,3 +322,14 @@ my_bool vio_poll_read(Vio *vio,uint timeout) DBUG_RETURN(fds.revents & POLLIN ? 0 : 1); #endif } + + +void vio_timeout(Vio *vio __attribute__((unused)), + uint timeout __attribute__((unused))) +{ +#ifdef __WIN__ + ulong wait_timeout= (ulong) timeout * 1000; + (void) setsockopt(vio->sd, SOL_SOCKET, SO_RCVTIMEO, (char*) &wait_timeout, + sizeof(wait_timeout)); +#endif /* __WIN__ */ +} diff --git a/vio/viossl.c b/vio/viossl.c index fc95b0755ce..fafe48b7a84 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -21,23 +21,10 @@ the file descriptior. */ -#include +#include "vio_priv.h" #ifdef HAVE_OPENSSL -#include - -#include -#include -#include -#include -#include -#include - -#ifndef __WIN__ -#define HANDLE void * -#endif - static void report_errors() { @@ -88,11 +75,11 @@ int vio_ssl_read(Vio * vio, gptr buf, int size) int r; DBUG_ENTER("vio_ssl_read"); DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d, ssl_=%p", - vio->sd, buf, size, vio->ssl_)); + vio->sd, buf, size, vio->ssl_arg)); - if ((r= SSL_read(vio->ssl_, buf, size)) < 0) + if ((r= SSL_read((SSL*) vio->ssl_arg, buf, size)) < 0) { - int err= SSL_get_error(vio->ssl_, r); + int err= SSL_get_error((SSL*) vio->ssl_arg, r); DBUG_PRINT("error",("SSL_read(): %d SSL_get_error(): %d", r, err)); report_errors(); } @@ -107,7 +94,7 @@ int vio_ssl_write(Vio * vio, const gptr buf, int size) DBUG_ENTER("vio_ssl_write"); DBUG_PRINT("enter", ("sd=%d, buf=%p, size=%d", vio->sd, buf, size)); - if ((r= SSL_write(vio->ssl_, buf, size)) < 0) + if ((r= SSL_write((SSL*) vio->ssl_arg, buf, size)) < 0) report_errors(); DBUG_PRINT("exit", ("%d", r)); DBUG_RETURN(r); @@ -171,11 +158,11 @@ int vio_ssl_close(Vio * vio) int r; DBUG_ENTER("vio_ssl_close"); r=0; - if (vio->ssl_) + if ((SSL*) vio->ssl_arg) { - r = SSL_shutdown(vio->ssl_); - SSL_free(vio->ssl_); - vio->ssl_= 0; + r = SSL_shutdown((SSL*) vio->ssl_arg); + SSL_free((SSL*) vio->ssl_arg); + vio->ssl_arg= 0; } if (vio->sd >= 0) { @@ -273,8 +260,8 @@ int sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) net_blocking = vio_is_blocking(vio); vio_blocking(vio, 1, &unused); /* Must be called before reset */ vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); - vio->ssl_=0; - if (!(vio->ssl_ = SSL_new(ptr->ssl_context_))) + vio->ssl_arg= 0; + if (!(vio->ssl_arg= (void*) SSL_new(ptr->ssl_context))) { DBUG_PRINT("error", ("SSL_new failure")); report_errors(); @@ -282,25 +269,25 @@ int sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } - DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); - SSL_clear(vio->ssl_); - SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); - SSL_set_fd(vio->ssl_,vio->sd); - SSL_set_accept_state(vio->ssl_); - if (SSL_do_handshake(vio->ssl_) < 1) + DBUG_PRINT("info", ("ssl_=%p timeout=%ld",(SSL*) vio->ssl_arg, timeout)); + SSL_clear((SSL*) vio->ssl_arg); + SSL_SESSION_set_timeout(SSL_get_session((SSL*) vio->ssl_arg), timeout); + SSL_set_fd((SSL*) vio->ssl_arg,vio->sd); + SSL_set_accept_state((SSL*) vio->ssl_arg); + if (SSL_do_handshake((SSL*) vio->ssl_arg) < 1) { DBUG_PRINT("error", ("SSL_do_handshake failure")); report_errors(); - SSL_free(vio->ssl_); - vio->ssl_=0; + SSL_free((SSL*) vio->ssl_arg); + vio->ssl_arg= 0; vio_reset(vio, old_type,vio->sd,0,FALSE); vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } #ifndef DBUF_OFF DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" - ,SSL_get_cipher_name(vio->ssl_))); - client_cert = SSL_get_peer_certificate (vio->ssl_); + ,SSL_get_cipher_name((SSL*) vio->ssl_arg))); + client_cert = SSL_get_peer_certificate ((SSL*) vio->ssl_arg); if (client_cert != NULL) { DBUG_PRINT("info",("Client certificate:")); @@ -317,7 +304,7 @@ int sslaccept(struct st_VioSSLAcceptorFd* ptr, Vio* vio, long timeout) else DBUG_PRINT("info",("Client does not have certificate.")); - str=SSL_get_shared_ciphers(vio->ssl_, buf, sizeof(buf)); + str=SSL_get_shared_ciphers((SSL*) vio->ssl_arg, buf, sizeof(buf)); if (str) { DBUG_PRINT("info",("SSL_get_shared_ciphers() returned '%s'",str)); @@ -340,14 +327,14 @@ int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) my_bool net_blocking; enum enum_vio_type old_type; DBUG_ENTER("sslconnect"); - DBUG_PRINT("enter", ("sd=%d ptr=%p ctx: %p", vio->sd,ptr,ptr->ssl_context_)); + DBUG_PRINT("enter", ("sd=%d ptr=%p ctx: %p", vio->sd,ptr,ptr->ssl_context)); old_type= vio->type; net_blocking = vio_is_blocking(vio); vio_blocking(vio, 1, &unused); /* Must be called before reset */ vio_reset(vio,VIO_TYPE_SSL,vio->sd,0,FALSE); - vio->ssl_=0; - if (!(vio->ssl_ = SSL_new(ptr->ssl_context_))) + vio->ssl_arg= 0; + if (!(vio->ssl_arg = SSL_new(ptr->ssl_context))) { DBUG_PRINT("error", ("SSL_new failure")); report_errors(); @@ -355,25 +342,25 @@ int sslconnect(struct st_VioSSLConnectorFd* ptr, Vio* vio, long timeout) vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } - DBUG_PRINT("info", ("ssl_=%p timeout=%ld",vio->ssl_, timeout)); - SSL_clear(vio->ssl_); - SSL_SESSION_set_timeout(SSL_get_session(vio->ssl_), timeout); - SSL_set_fd (vio->ssl_, vio->sd); - SSL_set_connect_state(vio->ssl_); - if (SSL_do_handshake(vio->ssl_) < 1) + DBUG_PRINT("info", ("ssl_=%p timeout=%ld",(SSL*) vio->ssl_arg, timeout)); + SSL_clear((SSL*) vio->ssl_arg); + SSL_SESSION_set_timeout(SSL_get_session((SSL*) vio->ssl_arg), timeout); + SSL_set_fd ((SSL*) vio->ssl_arg, vio->sd); + SSL_set_connect_state((SSL*) vio->ssl_arg); + if (SSL_do_handshake((SSL*) vio->ssl_arg) < 1) { DBUG_PRINT("error", ("SSL_do_handshake failure")); report_errors(); - SSL_free(vio->ssl_); - vio->ssl_=0; + SSL_free((SSL*) vio->ssl_arg); + vio->ssl_arg= 0; vio_reset(vio, old_type,vio->sd,0,FALSE); vio_blocking(vio, net_blocking, &unused); DBUG_RETURN(1); } #ifndef DBUG_OFF DBUG_PRINT("info",("SSL_get_cipher_name() = '%s'" - ,SSL_get_cipher_name(vio->ssl_))); - server_cert = SSL_get_peer_certificate (vio->ssl_); + ,SSL_get_cipher_name((SSL*) vio->ssl_arg))); + server_cert = SSL_get_peer_certificate ((SSL*) vio->ssl_arg); if (server_cert != NULL) { DBUG_PRINT("info",("Server certificate:")); @@ -407,4 +394,10 @@ int vio_ssl_blocking(Vio * vio __attribute__((unused)), return set_blocking_mode ? 0 : 1; } + +void vio_ssl_timeout(Vio *vio __attribute__((unused)), + uint timeout __attribute__((unused))) +{ + /* Not yet implemented (non critical) */ +} #endif /* HAVE_OPENSSL */ diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index 69d4f3007b8..0997e3909db 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -14,15 +14,10 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include +#include "vio_priv.h" #ifdef HAVE_OPENSSL -#include -#include -#include - - static bool ssl_algorithms_added = FALSE; static bool ssl_error_strings_loaded= FALSE; static int verify_depth = 0; @@ -203,8 +198,8 @@ new_VioSSLConnectorFd(const char* key_file, my_malloc(sizeof(struct st_VioSSLConnectorFd),MYF(0))))) DBUG_RETURN(0); - ptr->ssl_context_= 0; - ptr->ssl_method_= 0; + ptr->ssl_context= 0; + ptr->ssl_method= 0; /* FIXME: constants! */ if (!ssl_algorithms_added) @@ -219,10 +214,10 @@ new_VioSSLConnectorFd(const char* key_file, ssl_error_strings_loaded = TRUE; SSL_load_error_strings(); } - ptr->ssl_method_ = TLSv1_client_method(); - ptr->ssl_context_ = SSL_CTX_new(ptr->ssl_method_); - DBUG_PRINT("info", ("ssl_context_: %p",ptr->ssl_context_)); - if (ptr->ssl_context_ == 0) + ptr->ssl_method = TLSv1_client_method(); + ptr->ssl_context = SSL_CTX_new(ptr->ssl_method); + DBUG_PRINT("info", ("ssl_context: %p",ptr->ssl_context)); + if (ptr->ssl_context == 0) { DBUG_PRINT("error", ("SSL_CTX_new failed")); report_errors(); @@ -234,20 +229,20 @@ new_VioSSLConnectorFd(const char* key_file, */ if (cipher) { - result=SSL_CTX_set_cipher_list(ptr->ssl_context_, cipher); + result=SSL_CTX_set_cipher_list(ptr->ssl_context, cipher); DBUG_PRINT("info",("SSL_set_cipher_list() returned %d",result)); } - SSL_CTX_set_verify(ptr->ssl_context_, verify, vio_verify_callback); - if (vio_set_cert_stuff(ptr->ssl_context_, cert_file, key_file) == -1) + SSL_CTX_set_verify(ptr->ssl_context, verify, vio_verify_callback); + if (vio_set_cert_stuff(ptr->ssl_context, cert_file, key_file) == -1) { DBUG_PRINT("error", ("vio_set_cert_stuff failed")); report_errors(); goto ctor_failure; } - if (SSL_CTX_load_verify_locations( ptr->ssl_context_, ca_file,ca_path) == 0) + if (SSL_CTX_load_verify_locations( ptr->ssl_context, ca_file,ca_path) == 0) { DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed")); - if (SSL_CTX_set_default_verify_paths(ptr->ssl_context_) == 0) + if (SSL_CTX_set_default_verify_paths(ptr->ssl_context) == 0) { DBUG_PRINT("error", ("SSL_CTX_set_default_verify_paths failed")); report_errors(); @@ -257,7 +252,7 @@ new_VioSSLConnectorFd(const char* key_file, /* DH stuff */ dh=get_dh512(); - SSL_CTX_set_tmp_dh(ptr->ssl_context_,dh); + SSL_CTX_set_tmp_dh(ptr->ssl_context,dh); DH_free(dh); DBUG_RETURN(ptr); @@ -292,10 +287,10 @@ new_VioSSLAcceptorFd(const char *key_file, ptr= ((struct st_VioSSLAcceptorFd*) my_malloc(sizeof(struct st_VioSSLAcceptorFd),MYF(0))); - ptr->ssl_context_=0; - ptr->ssl_method_=0; + ptr->ssl_context=0; + ptr->ssl_method=0; /* FIXME: constants! */ - ptr->session_id_context_ = ptr; + ptr->session_id_context= ptr; if (!ssl_algorithms_added) { @@ -310,9 +305,9 @@ new_VioSSLAcceptorFd(const char *key_file, ssl_error_strings_loaded = TRUE; SSL_load_error_strings(); } - ptr->ssl_method_= TLSv1_server_method(); - ptr->ssl_context_= SSL_CTX_new(ptr->ssl_method_); - if (ptr->ssl_context_ == 0) + ptr->ssl_method= TLSv1_server_method(); + ptr->ssl_context= SSL_CTX_new(ptr->ssl_method); + if (ptr->ssl_context == 0) { DBUG_PRINT("error", ("SSL_CTX_new failed")); report_errors(); @@ -320,31 +315,31 @@ new_VioSSLAcceptorFd(const char *key_file, } if (cipher) { - result=SSL_CTX_set_cipher_list(ptr->ssl_context_, cipher); + result=SSL_CTX_set_cipher_list(ptr->ssl_context, cipher); DBUG_PRINT("info",("SSL_set_cipher_list() returned %d",result)); } /* SSL_CTX_set_quiet_shutdown(ctx,1); */ - SSL_CTX_sess_set_cache_size(ptr->ssl_context_,128); + SSL_CTX_sess_set_cache_size(ptr->ssl_context,128); /* DH? */ - SSL_CTX_set_verify(ptr->ssl_context_, verify, vio_verify_callback); - SSL_CTX_set_session_id_context(ptr->ssl_context_, - (const uchar*) &(ptr->session_id_context_), - sizeof(ptr->session_id_context_)); + SSL_CTX_set_verify(ptr->ssl_context, verify, vio_verify_callback); + SSL_CTX_set_session_id_context(ptr->ssl_context, + (const uchar*) &(ptr->session_id_context), + sizeof(ptr->session_id_context)); /* SSL_CTX_set_client_CA_list(ctx,SSL_load_client_CA_file(CAfile)); */ - if (vio_set_cert_stuff(ptr->ssl_context_, cert_file, key_file) == -1) + if (vio_set_cert_stuff(ptr->ssl_context, cert_file, key_file) == -1) { DBUG_PRINT("error", ("vio_set_cert_stuff failed")); report_errors(); goto ctor_failure; } - if (SSL_CTX_load_verify_locations( ptr->ssl_context_, ca_file, ca_path) == 0) + if (SSL_CTX_load_verify_locations( ptr->ssl_context, ca_file, ca_path) == 0) { DBUG_PRINT("warning", ("SSL_CTX_load_verify_locations failed")); - if (SSL_CTX_set_default_verify_paths(ptr->ssl_context_)==0) + if (SSL_CTX_set_default_verify_paths(ptr->ssl_context)==0) { DBUG_PRINT("error", ("SSL_CTX_set_default_verify_paths failed")); report_errors(); @@ -353,7 +348,7 @@ new_VioSSLAcceptorFd(const char *key_file, } /* DH stuff */ dh=get_dh512(); - SSL_CTX_set_tmp_dh(ptr->ssl_context_,dh); + SSL_CTX_set_tmp_dh(ptr->ssl_context,dh); DH_free(dh); DBUG_RETURN(ptr); @@ -362,6 +357,4 @@ ctor_failure: my_free((gptr) ptr,MYF(0)); DBUG_RETURN(0); } - - #endif /* HAVE_OPENSSL */ From b43a551e83c20dc647a56036ad76811bb09a4945 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 10:26:03 +0300 Subject: [PATCH 095/282] Add column names for metadata when running mysql with -T Change metadata info so that that MIN() and code MAX() reports that they can return NULL. Bug #324 client/mysql.cc: Add column names for metadata when running with -T mysql-test/r/show_check.result: test case for bug fix mysql-test/t/show_check.test: test case for bug fix sql/item_sum.cc: Change metadata info so that that MIN() and code MAX() reports that they can return NULL. Bug #324 sql/sql_load.cc: Removed not needed line --- client/mysql.cc | 5 +++-- mysql-test/r/show_check.result | 6 ++++++ mysql-test/t/show_check.test | 7 +++++++ sql/item_sum.cc | 7 ++++++- sql/sql_load.cc | 1 - 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index d4a06b34d32..639e5f450ad 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -1580,11 +1580,12 @@ print_field_types(MYSQL_RES *result) MYSQL_FIELD *field; while ((field = mysql_fetch_field(result))) { - tee_fprintf(PAGER,"%s '%s' %d %d %d %d %d\n", + tee_fprintf(PAGER,"Name: '%s'\nTable: '%s'\nType: %d\nLength: %d\nMax length: %d\nIs_null: %d\nFlags: %d\nDecimals: %d\n\n", field->name, field->table ? "" : field->table, (int) field->type, - field->length, field->max_length, + field->length, field->max_length, + !IS_NOT_NULL(field->flags), field->flags, field->decimals); } tee_puts("", PAGER); diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index fa2f381d905..f40b0693585 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -212,6 +212,12 @@ select * from t1; type_bool type_tiny type_short type_mediumint type_bigint type_decimal type_numeric empty_char type_char type_varchar type_timestamp type_date type_time type_datetime type_year type_enum type_set type_tinyblob type_blob type_medium_blob type_long_blob 0 1 NULL NULL NULL NULL NULL NULL NULL NULL 20030207100001 0000-00-00 00:00:00 0000-00-00 00:00:00 NULL NULL NULL NULL NULL NULL NULL drop table t1; +create table t1 (a int not null); +create table t2 select max(a) from t1; +show columns from t2; +Field Type Null Key Default Extra +max(a) bigint(20) YES NULL +drop table t1,t2; create table t1 (c decimal, d double, f float, r real); show columns from t1; Field Type Null Key Default Extra diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index ba6fa930e22..2cd2012d109 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -114,6 +114,13 @@ insert into t1 (type_timestamp) values ("2003-02-07 10:00:01"); select * from t1; drop table t1; +# +# Check metadata +# +create table t1 (a int not null); +create table t2 select max(a) from t1; +show columns from t2; +drop table t1,t2; # Check auto conversions of types diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 08385bb9ca6..835278ae262 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -46,7 +46,11 @@ Item_sum::Item_sum(List &list) void Item_sum::make_field(Send_field *tmp_field) { if (args[0]->type() == Item::FIELD_ITEM && keep_field_type()) + { ((Item_field*) args[0])->field->make_field(tmp_field); + if (maybe_null) + tmp_field->flags&= ~NOT_NULL_FLAG; + } else { tmp_field->flags=0; @@ -158,7 +162,8 @@ Item_sum_hybrid::fix_fields(THD *thd,TABLE_LIST *tables) else max_length=item->max_length; decimals=item->decimals; - maybe_null=item->maybe_null; + /* MIN/MAX can return NULL for empty set indepedent of the used column */ + maybe_null= 1; binary=item->binary; unsigned_flag=item->unsigned_flag; result_field=0; diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 2e7bf1d5d78..0ae6ccb4c4a 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -165,7 +165,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, } else { - read_file_from_client=0; #ifdef DONT_ALLOW_FULL_LOAD_DATA_PATHS ex->file_name+=dirname_length(ex->file_name); #endif From 9ed16ed13a7b5640cff4c888efefd6356df46fd5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 12:26:21 +0200 Subject: [PATCH 096/282] - added missing file vio_priv.h to source distribution --- vio/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vio/Makefile.am b/vio/Makefile.am index ab8fac51ee7..56ab21e8922 100644 --- a/vio/Makefile.am +++ b/vio/Makefile.am @@ -18,7 +18,7 @@ INCLUDES= -I$(srcdir)/../include -I../include $(openssl_includes) LDADD= @CLIENT_EXTRA_LDFLAGS@ $(openssl_libs) pkglib_LIBRARIES= libvio.a noinst_PROGRAMS = test-ssl test-sslserver test-sslclient -noinst_HEADERS= +noinst_HEADERS= vio_priv.h test_ssl_SOURCES= test-ssl.c test_ssl_LDADD= @CLIENT_EXTRA_LDFLAGS@ ../dbug/libdbug.a libvio.a \ ../mysys/libmysys.a ../strings/libmystrings.a \ From 8a920b6133f2485ad332c0cd33d6786ff964239d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 15:24:52 +0300 Subject: [PATCH 097/282] sql_union.cc: Post merge fixes sql/sql_union.cc: Post merge fixes --- sql/sql_union.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 57fc026f4f4..ce79a3c4ad5 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -259,7 +259,7 @@ int st_select_lex_unit::exec() } for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select()) { - ha_rows rows= 0; + ha_rows records_at_start= 0; thd->lex.current_select= sl; if (optimized) From cd822e347bca8531e671ca884ac08866e122f9e5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 15:32:52 +0300 Subject: [PATCH 098/282] Merge fixes sql/sql_union.cc: Some further merge fixes --- sql/sql_union.cc | 53 +++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 28 deletions(-) diff --git a/sql/sql_union.cc b/sql/sql_union.cc index ce79a3c4ad5..24497589c73 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -187,34 +187,31 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result, for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select()) { - for (SELECT_LEX *sl= select_cursor; sl; sl= sl->next_select()) - { - JOIN *join= new JOIN(thd, sl->item_list, - sl->options | thd->options | SELECT_NO_UNLOCK, - union_result); - thd->lex.current_select= sl; - offset_limit_cnt= sl->offset_limit; - select_limit_cnt= sl->select_limit+sl->offset_limit; - if (select_limit_cnt < sl->select_limit) - select_limit_cnt= HA_POS_ERROR; // no limit - if (select_limit_cnt == HA_POS_ERROR || sl->braces) - sl->options&= ~OPTION_FOUND_ROWS; - - res= join->prepare(&sl->ref_pointer_array, - (TABLE_LIST*) sl->table_list.first, sl->with_wild, - sl->where, - ((sl->braces) ? sl->order_list.elements : 0) + - sl->group_list.elements, - (sl->braces) ? - (ORDER *)sl->order_list.first : (ORDER *) 0, - (ORDER*) sl->group_list.first, - sl->having, - (ORDER*) NULL, - sl, this, t_and_f); - t_and_f= 0; - if (res || thd->is_fatal_error) - goto err; - } + JOIN *join= new JOIN(thd, sl->item_list, + sl->options | thd->options | SELECT_NO_UNLOCK, + union_result); + thd->lex.current_select= sl; + offset_limit_cnt= sl->offset_limit; + select_limit_cnt= sl->select_limit+sl->offset_limit; + if (select_limit_cnt < sl->select_limit) + select_limit_cnt= HA_POS_ERROR; // no limit + if (select_limit_cnt == HA_POS_ERROR || sl->braces) + sl->options&= ~OPTION_FOUND_ROWS; + + res= join->prepare(&sl->ref_pointer_array, + (TABLE_LIST*) sl->table_list.first, sl->with_wild, + sl->where, + ((sl->braces) ? sl->order_list.elements : 0) + + sl->group_list.elements, + (sl->braces) ? + (ORDER *)sl->order_list.first : (ORDER *) 0, + (ORDER*) sl->group_list.first, + sl->having, + (ORDER*) NULL, + sl, this, t_and_f); + t_and_f= 0; + if (res || thd->is_fatal_error) + goto err; } item_list.empty(); From 5f8cc0998f6366c46cc20e42e4989f8f3f468f03 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 18:03:39 +0500 Subject: [PATCH 099/282] Fix for bug #799 FLUSH TABLES WITH READ LOCK does not block CREATE TABLE --- mysql-test/r/drop.result | 10 ++++++++++ mysql-test/t/drop.test | 10 ++++++++++ sql/sql_table.cc | 17 +++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 367b28e9bf7..dbb6800cb75 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -44,3 +44,13 @@ mysql test drop database mysqltest; ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist +drop table t1; +flush tables with read lock; +create table t1(n int); +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +unlock tables; +create table t1(n int); +show tables; +Tables_in_test +t1 +drop table t1; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index a55cbb45fd9..78311a9dd52 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -43,3 +43,13 @@ drop database mysqltest; show databases; --error 1008 drop database mysqltest; + +# test create table and FLUSH TABLES WITH READ LOCK +drop table t1; +flush tables with read lock; +--error 1099; +create table t1(n int); +unlock tables; +create table t1(n int); +show tables; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 37f8d0d7f4f..f33cc8fde14 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -900,6 +900,23 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, DBUG_RETURN(-1); } VOID(pthread_mutex_lock(&LOCK_open)); + if (global_read_lock) + { + thd->mysys_var->current_mutex= &LOCK_open; + thd->mysys_var->current_cond= &COND_refresh; + if (thd->global_read_lock) + my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), + table_name); + else + while (global_read_lock && ! thd->killed) + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + pthread_mutex_lock(&thd->mysys_var->mutex); + thd->mysys_var->current_mutex= 0; + thd->mysys_var->current_cond= 0; + pthread_mutex_unlock(&thd->mysys_var->mutex); + if (error) + goto end; + } if (!tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { if (!access(path,F_OK)) From 59de978b8938f4ce16bb314e5c17ae68270ebb6c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 19:22:14 +0300 Subject: [PATCH 100/282] Added a warning to my_print_defaults if --verbose is given and --defaults-file is a non-existing or non-regular file. Bug#755 scripts/mysqld_safe.sh: Added a warning to my_print_defaults if --verbose is given and --defaults-file is a non-existing or non-regular file. Bug#755 --- extra/my_print_defaults.c | 29 ++++++++++++++++--- include/my_sys.h | 4 +-- include/mysql_com.h | 4 +-- mysys/default.c | 59 ++++++++++++++++++++++----------------- scripts/mysqld_safe.sh | 2 +- 5 files changed, 64 insertions(+), 34 deletions(-) diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index c0f8a54f432..549b2124b55 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -26,6 +26,7 @@ #include const char *config_file="my"; /* Default config file */ +uint verbose= 0, opt_defaults_file_used= 0; static struct my_option my_long_options[] = { @@ -47,6 +48,8 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Increase the output level", + 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} @@ -55,7 +58,7 @@ static struct my_option my_long_options[] = static void usage(my_bool version) { - printf("%s Ver 1.5 for %s at %s\n",my_progname,SYSTEM_TYPE, + printf("%s Ver 1.6 for %s at %s\n",my_progname,SYSTEM_TYPE, MACHINE_TYPE); if (version) return; @@ -73,12 +76,18 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument __attribute__((unused))) { switch (optid) { + case 'c': + opt_defaults_file_used= 1; + break; case 'n': exit(0); case 'I': case '?': usage(0); exit(0); + case 'v': + verbose++; + break; case 'V': usage(1); exit(0); @@ -104,7 +113,7 @@ static int get_options(int *argc,char ***argv) int main(int argc, char **argv) { - int count; + int count, error; char **load_default_groups, *tmp_arguments[2], **argument, **arguments; MY_INIT(argv[0]); @@ -126,8 +135,20 @@ int main(int argc, char **argv) arguments=tmp_arguments; arguments[0]=my_progname; arguments[1]=0; - load_defaults(config_file, (const char **) load_default_groups, - &count, &arguments); + if ((error= load_defaults(config_file, (const char **) load_default_groups, + &count, &arguments)) > 1) + { + if (verbose && opt_defaults_file_used) + { + if (error == 2) + fprintf(stderr, "WARNING: Defaults file (%s) not found!\n", + config_file); + if (error == 3) + fprintf(stderr, "WARNING: Defaults file (%s) is not a regular file!\n", + config_file); + } + exit(2); // Non-fatal error + } for (argument= arguments+1 ; *argument ; argument++) puts(*argument); diff --git a/include/my_sys.h b/include/my_sys.h index 9f4b91c8bf6..7a3d22f3304 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -742,8 +742,8 @@ extern void set_prealloc_root(MEM_ROOT *root, char *ptr); extern char *strdup_root(MEM_ROOT *root,const char *str); extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); -extern void load_defaults(const char *conf_file, const char **groups, - int *argc, char ***argv); +extern int load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv); extern void free_defaults(char **argv); extern void print_defaults(const char *conf_file, const char **groups); extern my_bool my_compress(byte *, ulong *, ulong *); diff --git a/include/mysql_com.h b/include/mysql_com.h index 945372563b0..6daf26bc2ac 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -242,8 +242,8 @@ void hash_password(unsigned long *result, const char *password); /* Some other useful functions */ void my_init(void); -void load_defaults(const char *conf_file, const char **groups, - int *argc, char ***argv); +int load_defaults(const char *conf_file, const char **groups, + int *argc, char ***argv); my_bool my_thread_init(void); void my_thread_end(void); diff --git a/mysys/default.c b/mysys/default.c index cdacc8bee2b..716be6fc2bb 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -66,13 +66,13 @@ NullS, #define windows_ext ".ini" #endif -static my_bool search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc, - const char *dir, const char *config_file, - const char *ext, TYPELIB *group); +static int search_default_file(DYNAMIC_ARRAY *args,MEM_ROOT *alloc, + const char *dir, const char *config_file, + const char *ext, TYPELIB *group); static char *remove_end_comment(char *ptr); -void load_defaults(const char *conf_file, const char **groups, +int load_defaults(const char *conf_file, const char **groups, int *argc, char ***argv) { DYNAMIC_ARRAY args; @@ -80,6 +80,7 @@ void load_defaults(const char *conf_file, const char **groups, TYPELIB group; my_bool found_print_defaults=0; uint args_used=0; + int error= 0; MEM_ROOT alloc; char *ptr,**res; DBUG_ENTER("load_defaults"); @@ -100,7 +101,7 @@ void load_defaults(const char *conf_file, const char **groups, (*argc)--; *argv=res; *(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */ - DBUG_VOID_RETURN; + return 0; } /* Check if we want to force the use a specific default file */ @@ -129,14 +130,14 @@ void load_defaults(const char *conf_file, const char **groups, goto err; if (forced_default_file) { - if (search_default_file(&args, &alloc, "", forced_default_file, "", - &group)) + if ((error= search_default_file(&args, &alloc, "", + forced_default_file, "", &group)) == 1) goto err; } else if (dirname_length(conf_file)) { - if (search_default_file(&args, &alloc, NullS, conf_file, default_ext, - &group)) + if ((error= search_default_file(&args, &alloc, NullS, conf_file, + default_ext, &group)) == 1) goto err; } else @@ -144,26 +145,25 @@ void load_defaults(const char *conf_file, const char **groups, #ifdef __WIN__ char system_dir[FN_REFLEN]; GetWindowsDirectory(system_dir,sizeof(system_dir)); - if (search_default_file(&args, &alloc, system_dir, conf_file, windows_ext, - &group)) + if ((error= search_default_file(&args, &alloc, system_dir, conf_file, + windows_ext, &group)) == 1) goto err; #endif #if defined(__EMX__) || defined(OS2) if (getenv("ETC") && - search_default_file(&args, &alloc, getenv("ETC"), conf_file, - default_ext, &group)) + (error= search_default_file(&args, &alloc, getenv("ETC"), conf_file, + default_ext, &group)) == 1) goto err; #endif for (dirs=default_directories ; *dirs; dirs++) { - int error=0; if (**dirs) - error=search_default_file(&args, &alloc, *dirs, conf_file, - default_ext, &group); + error= search_default_file(&args, &alloc, *dirs, conf_file, + default_ext, &group); else if (defaults_extra_file) - error=search_default_file(&args, &alloc, NullS, defaults_extra_file, - default_ext, &group); - if (error) + error= search_default_file(&args, &alloc, NullS, defaults_extra_file, + default_ext, &group); + if (error == 1) goto err; } } @@ -204,11 +204,11 @@ void load_defaults(const char *conf_file, const char **groups, puts(""); exit(1); } - DBUG_VOID_RETURN; + return error; err: fprintf(stderr,"Program aborted\n"); - exit(1); + return(error); } @@ -220,9 +220,16 @@ void free_defaults(char **argv) } -static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, - const char *dir, const char *config_file, - const char *ext, TYPELIB *group) +/* + Return values: 0 Success + 1 Fatal error, abort + 2 File not found, continue + 3 File is not a regular file, continue +*/ + +static int search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, + const char *dir, const char *config_file, + const char *ext, TYPELIB *group) { char name[FN_REFLEN+10],buff[4096],*ptr,*end,*value,*tmp; FILE *fp; @@ -247,7 +254,7 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, { MY_STAT stat_info; if (!my_stat(name,&stat_info,MYF(0))) - return 0; + return 2; /* Ignore world-writable regular files. This is mainly done to protect us to not read a file created by @@ -260,6 +267,8 @@ static my_bool search_default_file(DYNAMIC_ARRAY *args, MEM_ROOT *alloc, name); return 0; } + else if ((stat_info.st_mode & S_IFMT) != S_IFREG) + return 3; } #endif if (!(fp = my_fopen(fn_format(name,name,"","",4),O_RDONLY,MYF(0)))) diff --git a/scripts/mysqld_safe.sh b/scripts/mysqld_safe.sh index d7e3eedb84e..1c056e963cb 100644 --- a/scripts/mysqld_safe.sh +++ b/scripts/mysqld_safe.sh @@ -148,7 +148,7 @@ else fi args= -parse_arguments `$print_defaults $defaults mysqld server mysqld_safe safe_mysqld` +parse_arguments `$print_defaults --loose-verbose $defaults mysqld server mysqld_safe safe_mysqld` parse_arguments PICK-ARGS-FROM-ARGV "$@" if test ! -x $ledir/$MYSQLD From d2f12f719f73e849c538058a42766588a8d6e11c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 12:22:42 -0400 Subject: [PATCH 101/282] Updating translation for Spanish/Portuguese error messages files sql/share/portuguese/errmsg.txt: Updating Translation sql/share/spanish/errmsg.txt: Updating Translation --- sql/share/portuguese/errmsg.txt | 40 ++++++++++++++++----------------- sql/share/spanish/errmsg.txt | 34 ++++++++++++++-------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/sql/share/portuguese/errmsg.txt b/sql/share/portuguese/errmsg.txt index f9f37bfd924..89af701f21a 100644 --- a/sql/share/portuguese/errmsg.txt +++ b/sql/share/portuguese/errmsg.txt @@ -219,23 +219,23 @@ "Não pode acrescentar uma restrição de chave estrangeira", "Não pode acrescentar uma linha filha: uma restrição de chave estrangeira falhou", "Não pode apagar uma linha pai: uma restrição de chave estrangeira falhou", -"Error connecting to master: %-.128s", -"Error running query on master: %-.128s", -"Error when executing command %s: %-.128s", -"Wrong usage of %s and %s", -"The used SELECT statements have a different number of columns", -"Can't execute the query because you have a conflicting read lock", -"Mixing of transactional and non-transactional tables is disabled", -"Option '%s' used twice in statement", -"User '%-.64s' has exceeded the '%s' resource (current value: %ld)", -"Access denied. You need the %-.128s privilege for this operation", -"Variable '%-.64s' is a LOCAL variable and can't be used with SET GLOBAL", -"Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL", -"Variable '%-.64s' doesn't have a default value", -"Variable '%-.64s' can't be set to the value of '%-.64s'", -"Wrong argument type to variable '%-.64s'", -"Variable '%-.64s' can only be set, not read", -"Wrong usage/placement of '%s'", -"This version of MySQL doesn't yet support '%s'", -"Got fatal error %d: '%-.128s' from master when reading data from binary log", -"Slave SQL thread ignored the query because of replicate-*-table rules" +"Erro conectando com o master: %-.128s", +"Erro rodando consulta no master: %-.128s", +"Erro quando executando comando %s: %-.128s", +"Uso errado de %s e %s", +"Os comandos SELECT usados têm diferente número de colunas", +"Não posso executar a consulta porque você tem um conflito de travamento de leitura", +"Mistura de tabelas transacional e não-transacional está desabilitada", +"Opção '%s' usada duas vezes no comando", +"Usuário '%-.64s' tem excedido o '%s' recurso (atual valor: %ld)", +"Acesso negado. Você precisa o privilégio %-.128s para essa operação", +"Variável '%-.64s' é uma LOCAL variável e não pode ser usada com SET GLOBAL", +"Variável '%-.64s' é uma GLOBAL variável e deve ser configurada com SET GLOBAL", +"Variável '%-.64s' não tem um valor padrão", +"Variável '%-.64s' não pode ser configurada para o valor de '%-.64s'", +"Tipo errado de argumento para variável '%-.64s'", +"Variável '%-.64s' somente pode ser configurada, não lida", +"Errado uso/colocação de '%s'", +"Esta versão de MySQL não suporta ainda '%s'", +"Obteve fatal erro %d: '%-.128s' do master quando lendo dados do binary log", +"Slave SQL thread ignorado a consulta devido às normas de replicação-*-tabela" diff --git a/sql/share/spanish/errmsg.txt b/sql/share/spanish/errmsg.txt index 78b7e5ac907..acb0b9fd2ab 100644 --- a/sql/share/spanish/errmsg.txt +++ b/sql/share/spanish/errmsg.txt @@ -223,20 +223,20 @@ "Error de coneccion a master: %-128s", "Error executando el query en master: %-128%", "Error de %s: %-128%", -"Wrong usage of %s and %s", -"The used SELECT statements have a different number of columns", -"Can't execute the query because you have a conflicting read lock", -"Mixing of transactional and non-transactional tables is disabled", -"Option '%s' used twice in statement", -"User '%-.64s' has exceeded the '%s' resource (current value: %ld)", -"Access denied. You need the %-.128s privilege for this operation", -"Variable '%-.64s' is a LOCAL variable and can't be used with SET GLOBAL", -"Variable '%-.64s' is a GLOBAL variable and should be set with SET GLOBAL", -"Variable '%-.64s' doesn't have a default value", -"Variable '%-.64s' can't be set to the value of '%-.64s'", -"Wrong argument type to variable '%-.64s'", -"Variable '%-.64s' can only be set, not read", -"Wrong usage/placement of '%s'", -"This version of MySQL doesn't yet support '%s'", -"Got fatal error %d: '%-.128s' from master when reading data from binary log", -"Slave SQL thread ignored the query because of replicate-*-table rules" +"Equivocado uso de %s y %s", +"El comando SELECT usado tiene diferente número de columnas", +"No puedo ejecutar el query porque usted tiene conflicto de traba de lectura", +"Mezla de transancional y no-transancional tablas está deshabilitada", +"Opción '%s' usada dos veces en el comando", +"Usuario '%-.64s' ha excedido el recurso '%s' (actual valor: %ld)", +"Acceso negado. Usted necesita el privilegio %-.128s para esta operación", +"Variable '%-.64s' es una LOCAL variable y no puede ser usada con SET GLOBAL", +"Variable '%-.64s' es una GLOBAL variable y no puede ser configurada con SET GLOBAL", +"Variable '%-.64s' no tiene un valor patrón", +"Variable '%-.64s' no puede ser configurada para el valor de '%-.64s'", +"Tipo de argumento equivocado para variable '%-.64s'", +"Variable '%-.64s' solamente puede ser configurada, no leída", +"Equivocado uso/colocación de '%s'", +"Esta versión de MySQL no soporta todavia '%s'", +"Recibió fatal error %d: '%-.128s' del master cuando leyendo datos del binary log", +"Slave SQL thread ignorado el query debido a las reglas de replicación-*-tabla" From c637296ceaf315d66011d0eeeae4765294fff060 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 27 Aug 2003 20:00:18 +0300 Subject: [PATCH 102/282] Fixed unlikely stack bug when having a BIG expression of type 1+1-1+1-1... in certain combinations. Bug #871 sql-bench/limits/mysql.cfg: Updated limits sql/item_cmpfunc.cc: Test for stack checking sql/item_func.cc: Test for stack checking --- sql-bench/limits/mysql.cfg | 100 ++++++++++++++++++++++++++++--------- sql/item_cmpfunc.cc | 2 +- sql/item_func.cc | 4 +- 3 files changed, 80 insertions(+), 26 deletions(-) diff --git a/sql-bench/limits/mysql.cfg b/sql-bench/limits/mysql.cfg index cebb85d8dfd..feaa79e43e9 100644 --- a/sql-bench/limits/mysql.cfg +++ b/sql-bench/limits/mysql.cfg @@ -177,7 +177,7 @@ compute=no # Compute ###> execute error:You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'compute sum(a) by a' at line 1 ### ###As far as some queries didnt return OK, result is NO -connections=99 # Simultaneous connections (installation default) +connections=101 # Simultaneous connections (installation default) constraint_check=syntax only # Column constraints ###< create table crash_q (a int check (a>0)) ###> OK @@ -345,7 +345,7 @@ date_format_inresult=iso # Date format in result ###> OK ### ###< select a from crash_me_d - ###> 2003-03-26 + ###> 2003-08-27 ###< delete from crash_me_d ###> OK date_infinity=error # Supports 'infinity dates @@ -695,7 +695,7 @@ func_extra_elt=yes # Function ELT func_extra_encrypt=yes # Function ENCRYPT ### ###2003-03-26 13:44:57 + ###>2003-08-27 19:55:21 func_extra_tail=no # Function TAIL ### ###4.0.12-debug + ###>4.0.15-debug-log func_extra_weekday=yes # Function WEEKDAY ### ###13:44:57 + ###>19:55:21 func_odbc_database=yes # Function DATABASE ### ###2003-03-26 + ###>2003-08-27 func_sql_current_time=yes # Function CURRENT_TIME ### ###2003-03-26 13:44:57 + ###>2003-08-27 19:55:21 func_sql_current_user=with_parenthesis # CURRENT_USER ###< select CURRENT_USER ###> execute error:Unknown column 'CURRENT_USER' in 'field list' @@ -1438,11 +1438,11 @@ func_sql_extract_sql=yes # Function EXTRACT func_sql_localtime=yes # Function LOCALTIME ### ###2003-03-26 13:44:57 + ###>2003-08-27 19:55:21 func_sql_lower=yes # Function LOWER ### ###