Merge bk-internal.mysql.com:/home/bk/mysql-4.1

into mysql.com:/home/my/mysql-4.1
This commit is contained in:
unknown 2005-02-02 22:28:22 +02:00
commit c30ccbcdb4
18 changed files with 65 additions and 54 deletions

View file

@ -2091,27 +2091,27 @@ static int dump_all_tables_in_db(char *database)
RETURN RETURN
void void
*/ */
static void get_actual_table_name( const char *old_table_name,
char *new_table_name, static void get_actual_table_name(const char *old_table_name,
int buf_size ) char *new_table_name,
int buf_size)
{ {
MYSQL_RES *tableRes; MYSQL_RES *tableRes;
MYSQL_ROW row; MYSQL_ROW row;
char query[ NAME_LEN + 50 ]; char query[ NAME_LEN + 50 ];
DBUG_ENTER("get_actual_table_name");
DBUG_ENTER("get_actual_table_name"); sprintf( query, "SHOW TABLES LIKE '%s'", old_table_name);
if (mysql_query_with_error_report(sock, 0, query))
{
safe_exit(EX_MYSQLERR);
}
sprintf( query, "SHOW TABLES LIKE '%s'", old_table_name ); tableRes= mysql_store_result( sock );
if (mysql_query_with_error_report(sock, 0, query)) row= mysql_fetch_row( tableRes );
{ strmake(new_table_name, row[0], buf_size-1);
safe_exit(EX_MYSQLERR); mysql_free_result(tableRes);
} }
tableRes = mysql_store_result( sock );
row = mysql_fetch_row( tableRes );
strncpy( new_table_name, row[0], buf_size );
mysql_free_result(tableRes);
} /* get_actual_table_name */
static int dump_selected_tables(char *db, char **table_names, int tables) static int dump_selected_tables(char *db, char **table_names, int tables)

View file

@ -213,12 +213,14 @@ int main(int argc,char *argv[])
string 'Unknown Error'. To avoid printing it we try to find the string 'Unknown Error'. To avoid printing it we try to find the
error string by asking for an impossible big error message. error string by asking for an impossible big error message.
*/ */
msg = strerror(10000); msg= strerror(10000);
/* allocate a buffer for unknown_error since strerror always returns the same pointer /*
on some platforms such as Windows */ Allocate a buffer for unknown_error since strerror always returns
unknown_error = malloc( strlen(msg)+1 ); the same pointer on some platforms such as Windows
strcpy( unknown_error, msg ); */
unknown_error= malloc(strlen(msg)+1);
strmov(unknown_error, msg);
for ( ; argc-- > 0 ; argv++) for ( ; argc-- > 0 ; argv++)
{ {
@ -271,7 +273,7 @@ int main(int argc,char *argv[])
/* if we allocated a buffer for unknown_error, free it now */ /* if we allocated a buffer for unknown_error, free it now */
if (unknown_error) if (unknown_error)
free(unknown_error); free(unknown_error);
exit(error); exit(error);
return error; return error;

View file

@ -80,10 +80,6 @@ memory is read outside the allocated blocks. */
/* Make a non-inline debug version */ /* Make a non-inline debug version */
#ifdef DBUG_ON
#define UNIV_DEBUG
#endif /* DBUG_ON */
/* /*
#define UNIV_DEBUG #define UNIV_DEBUG
#define UNIV_MEM_DEBUG #define UNIV_MEM_DEBUG

View file

@ -39,3 +39,6 @@ DROP TABLE t1;
SELECT CHAR(31) = '', '' = CHAR(31); SELECT CHAR(31) = '', '' = CHAR(31);
CHAR(31) = '' '' = CHAR(31) CHAR(31) = '' '' = CHAR(31)
0 0 0 0
SELECT CHAR(30) = '', '' = CHAR(30);
CHAR(30) = '' '' = CHAR(30)
0 0

View file

@ -33,3 +33,5 @@ DROP TABLE t1;
# Bug #8134: Comparison against CHAR(31) at end of string # Bug #8134: Comparison against CHAR(31) at end of string
SELECT CHAR(31) = '', '' = CHAR(31); SELECT CHAR(31) = '', '' = CHAR(31);
# Extra test
SELECT CHAR(30) = '', '' = CHAR(30);

View file

@ -43,7 +43,7 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
return 0; return 0;
if (skip_end_space && a_length != b_length) if (skip_end_space && a_length != b_length)
{ {
int swap= 0; int swap= 1;
/* /*
We are using space compression. We have to check if longer key We are using space compression. We have to check if longer key
has next character < ' ', in which case it's less than the shorter has next character < ' ', in which case it's less than the shorter
@ -57,12 +57,12 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
/* put shorter key in a */ /* put shorter key in a */
a_length= b_length; a_length= b_length;
a= b; a= b;
swap= -1 ^ 1; /* swap sign of result */ swap= -1; /* swap sign of result */
} }
for (end= a + a_length-length; a < end ; a++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
return 0; return 0;
} }

View file

@ -2272,7 +2272,10 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table,
strxmov(src_path, (*tmp_table)->path, reg_ext, NullS); strxmov(src_path, (*tmp_table)->path, reg_ext, NullS);
else else
{ {
fn_format( src_path, src_table, src_db, reg_ext, MYF(MY_UNPACK_FILENAME)); strxmov(src_path, mysql_data_home, "/", src_db, "/", src_table,
reg_ext, NullS);
/* Resolve symlinks (for windows) */
fn_format(src_path, src_path, "", "", MYF(MY_UNPACK_FILENAME));
if (access(src_path, F_OK)) if (access(src_path, F_OK))
{ {
my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table); my_error(ER_BAD_TABLE_ERROR, MYF(0), src_table);
@ -2299,7 +2302,9 @@ int mysql_create_like_table(THD* thd, TABLE_LIST* table,
} }
else else
{ {
fn_format( dst_path, table_name, db, reg_ext, MYF(MY_UNPACK_FILENAME)); strxmov(dst_path, mysql_data_home, "/", db, "/", table_name,
reg_ext, NullS);
fn_format(dst_path, dst_path, "", "", MYF(MY_UNPACK_FILENAME));
if (!access(dst_path, F_OK)) if (!access(dst_path, F_OK))
goto table_exists; goto table_exists;
} }

View file

@ -167,7 +167,10 @@ int mysql_update(THD *thd,
else if ((used_index=table->file->key_used_on_scan) < MAX_KEY) else if ((used_index=table->file->key_used_on_scan) < MAX_KEY)
used_key_is_modified=check_if_key_used(table, used_index, fields); used_key_is_modified=check_if_key_used(table, used_index, fields);
else else
{
used_key_is_modified=0; used_key_is_modified=0;
used_index= MAX_KEY;
}
if (used_key_is_modified || order) if (used_key_is_modified || order)
{ {
/* /*

View file

@ -271,7 +271,7 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)),
if (!res && a_length != b_length) if (!res && a_length != b_length)
{ {
const uchar *end; const uchar *end;
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -286,7 +286,7 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)),
for (end= a + a_length-length; a < end ; a++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
} }
return res; return res;

View file

@ -157,7 +157,7 @@ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)),
} }
if (a_length != b_length) if (a_length != b_length)
{ {
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -172,7 +172,7 @@ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)),
for (end= a + a_length-length; a < end ; a++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
} }
return 0; return 0;

View file

@ -2632,7 +2632,7 @@ static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)),
if (!res && a_length != b_length) if (!res && a_length != b_length)
{ {
const uchar *end; const uchar *end;
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -2647,7 +2647,7 @@ static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)),
for (end= a + a_length-length; a < end ; a++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
} }
return res; return res;

View file

@ -611,7 +611,7 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
if (a != a_end || b != b_end) if (a != a_end || b != b_end)
{ {
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -626,7 +626,7 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)),
for ( ; a < a_end ; a++) for ( ; a < a_end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
} }
return 0; return 0;

View file

@ -389,7 +389,7 @@ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
} }
if (a_length != b_length) if (a_length != b_length)
{ {
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -404,7 +404,7 @@ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)),
for (end= a + a_length-length; a < end ; a++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
} }
return 0; return 0;

View file

@ -143,7 +143,7 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length,
} }
if (a_length != b_length) if (a_length != b_length)
{ {
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -153,12 +153,12 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length,
/* put shorter key in s */ /* put shorter key in s */
a_length= b_length; a_length= b_length;
a= b; a= b;
swap= -1^1; /* swap sign of result */ swap= -1; /* swap sign of result */
} }
for (end= a + a_length-length; a < end ; a++) for (end= a + a_length-length; a < end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
} }
return 0; return 0;

View file

@ -251,7 +251,7 @@ static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)),
int res= my_strnncoll_sjis_internal(cs, &a, a_length, &b, b_length); int res= my_strnncoll_sjis_internal(cs, &a, a_length, &b, b_length);
if (!res && (a != a_end || b != b_end)) if (!res && (a != a_end || b != b_end))
{ {
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -266,7 +266,7 @@ static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)),
for (; a < a_end ; a++) for (; a < a_end ; a++)
{ {
if (*a != ' ') if (*a != ' ')
return ((int) *a - (int) ' ') ^ swap; return (*a < ' ') ? -swap : swap;
} }
} }
return res; return res;

View file

@ -589,7 +589,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
} }
if (a_length != b_length) if (a_length != b_length)
{ {
int swap= 0; int swap= 1;
/* /*
Check the next not space character of the longer key. If it's < ' ', Check the next not space character of the longer key. If it's < ' ',
then it's smaller than the other key. then it's smaller than the other key.
@ -605,7 +605,7 @@ int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)),
{ {
if (*a != ' ') if (*a != ' ')
{ {
res= ((int) *a - (int) ' ') ^ swap; res= (*a < ' ') ? -swap : swap;
goto ret; goto ret;
} }
} }

View file

@ -275,7 +275,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)),
if (slen != tlen) if (slen != tlen)
{ {
int swap= 0; int swap= 1;
if (slen < tlen) if (slen < tlen)
{ {
s= t; s= t;
@ -286,7 +286,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)),
for ( ; s < se ; s+= 2) for ( ; s < se ; s+= 2)
{ {
if (s[0] || s[1] != ' ') if (s[0] || s[1] != ' ')
return (((int)s[0] << 8) + (int) s[1] - (int) ' ') ^ swap; return (s[0] == 0 && s[1] < ' ') ? -swap : swap;
} }
} }
return 0; return 0;

View file

@ -2077,7 +2077,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs,
if (slen != tlen) if (slen != tlen)
{ {
int swap= 0; int swap= 1;
if (slen < tlen) if (slen < tlen)
{ {
slen= tlen; slen= tlen;
@ -2098,7 +2098,7 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs,
for ( ; s < se; s++) for ( ; s < se; s++)
{ {
if (*s != ' ') if (*s != ' ')
return ((int)*s - (int) ' ') ^ swap; return (*s < ' ') ? -swap : swap;
} }
} }
return 0; return 0;