summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-04-27 22:12:08 +0300
committerunknown <monty@mashka.mysql.fi>2003-04-27 22:12:08 +0300
commitf22be777341f53b4deb58851828c0733ab5380bf (patch)
tree9cf8ed6360561508fc24e4f8cc90f56282626854 /sql
parent3e90ec6a582ec6a39209c00329ed93a7cc639ded (diff)
downloadmariadb-git-f22be777341f53b4deb58851828c0733ab5380bf.tar.gz
Fixed problem when comparing a key for a multi-byte-character set. (bug 152)
Use 0x.... as strings if 'new' mode. (bug 152) Don't report -max on windows when InnoDB is enabled. (bug 332) Reset current_linfo; This could cause a hang when doing PURGE LOGS. Fix for row numbers in EXPLAIN (bug 322) Fix that USE_FRM works for all table types (bug 97) VC++Files/libmysql/libmysql.dsp: Added new source files myisam/mi_key.c: Fixed problem when comparing a key for a multi-byte-character set. myisam/mi_range.c: Fixed problem when comparing a key for a multi-byte-character set. myisam/mi_rkey.c: Fixed problem when comparing a key for a multi-byte-character set. myisam/mi_search.c: Fixed problem when comparing a key for a multi-byte-character set. myisam/mi_test2.c: Fixed printf statements myisam/myisamdef.h: Fixed problem when comparing a key for a multi-byte-character set. myisam/sort.c: Fixed printf statements mysql-test/r/ctype_latin1_de.result: New test results mysql-test/r/join.result: New test results mysql-test/r/repair.result: New test results mysql-test/r/rpl_alter.result: New test results mysql-test/t/ctype_latin1_de-master.opt: --new is needed to get 0x... strings to work properly mysql-test/t/ctype_latin1_de.test: New test for latin1_de mysql-test/t/repair.test: Test of USE_FRM and HEAP tables sql/field.cc: Fixed problem when comparing a key for a multi-byte-character set. sql/item.cc: Use 0x.... as strings if 'new' mode sql/item.h: Use 0x.... as strings if 'new' mode sql/mysqld.cc: Don't report -max on windows when InnoDB is enabled. sql/sql_analyse.cc: Removed unused variable sql/sql_insert.cc: Removed debug message sql/sql_repl.cc: Reset current_linfo; This could cause a hang when doing PURGE LOGS. sql/sql_select.cc: Fix for row numbers in EXPLAIN sql/sql_table.cc: Fix that USE_FRM works for all table types (without strange errors) sql/sql_yacc.yy: Removed compiler warnings.
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc25
-rw-r--r--sql/item.cc8
-rw-r--r--sql/item.h2
-rw-r--r--sql/mysqld.cc4
-rw-r--r--sql/sql_analyse.cc1
-rw-r--r--sql/sql_insert.cc2
-rw-r--r--sql/sql_repl.cc3
-rw-r--r--sql/sql_select.cc3
-rw-r--r--sql/sql_table.cc30
-rw-r--r--sql/sql_yacc.yy6
10 files changed, 67 insertions, 17 deletions
diff --git a/sql/field.cc b/sql/field.cc
index eb7d3dc5686..a2663626723 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -162,6 +162,14 @@ static bool test_if_real(const char *str,int length)
}
+static inline uint field_length_without_space(const char *ptr, uint length)
+{
+ const char *end= ptr+length;
+ while (end > ptr && end[-1] == ' ')
+ end--;
+ return (uint) (end-ptr);
+}
+
/****************************************************************************
** Functions for the base classes
** This is an unpacked number.
@@ -3673,8 +3681,21 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr)
{
if (binary_flag)
return memcmp(a_ptr,b_ptr,field_length);
- else
- return my_sortcmp(a_ptr,b_ptr,field_length);
+#ifdef USE_STRCOLL
+ if (use_strcoll(default_charset_info))
+ {
+ /*
+ We have to remove end space to be able to compare multi-byte-characters
+ like in latin_de 'ae' and 0xe4
+ */
+ uint a_length= field_length_without_space(a_ptr, field_length);
+ uint b_length= field_length_without_space(b_ptr, field_length);
+ return my_strnncoll(default_charset_info,
+ (const uchar*) a_ptr, a_length,
+ (const uchar*) b_ptr, b_length);
+ }
+#endif
+ return my_sortcmp(a_ptr,b_ptr,field_length);
}
void Field_string::sort_string(char *to,uint length)
diff --git a/sql/item.cc b/sql/item.cc
index 4fefae7358f..79501755cbf 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -576,6 +576,14 @@ inline uint char_val(char X)
X-'a'+10);
}
+/* In MySQL 4.1 this will always return STRING_RESULT */
+
+enum Item_result Item_varbinary::result_type () const
+{
+ return (current_thd->variables.new_mode) ? STRING_RESULT : INT_RESULT;
+}
+
+
Item_varbinary::Item_varbinary(const char *str, uint str_length)
{
name=(char*) str-2; // Lex makes this start with 0x
diff --git a/sql/item.h b/sql/item.h
index 5e2c2ccc056..09d428509d0 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -353,7 +353,7 @@ public:
String *val_str(String*) { return &str_value; }
bool save_in_field(Field *field, bool no_conversions);
void make_field(Send_field *field);
- enum Item_result result_type () const { return INT_RESULT; }
+ enum Item_result result_type () const;
unsigned int size_of() { return sizeof(*this);}
};
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index fc2baf5784c..2799bdf9f54 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -204,12 +204,12 @@ static char **opt_argv;
#ifdef __WIN__
#undef MYSQL_SERVER_SUFFIX
#ifdef __NT__
-#if defined(HAVE_INNOBASE_DB) || defined(HAVE_BERKELEY_DB)
+#if defined(HAVE_BERKELEY_DB)
#define MYSQL_SERVER_SUFFIX "-max-nt"
#else
#define MYSQL_SERVER_SUFFIX "-nt"
#endif /* ...DB */
-#elif defined(HAVE_INNOBASE_DB) || defined(HAVE_BERKELEY_DB)
+#elif defined(HAVE_BERKELEY_DB)
#define MYSQL_SERVER_SUFFIX "-max"
#else
#define MYSQL_SERVER_SUFFIX ""
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 5d3f9a0595c..d6abe6497df 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -284,7 +284,6 @@ void field_str::add()
char buff[MAX_FIELD_WIDTH], *ptr;
String s(buff, sizeof(buff)), *res;
ulong length;
- TREE_ELEMENT *element;
if (!(res = item->val_str(&s)))
{
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 0379c1de287..e02f457fd77 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1029,7 +1029,7 @@ extern "C" pthread_handler_decl(handle_delayed_insert,arg)
#else
error=pthread_cond_timedwait(&di->cond,&di->mutex,&abstime);
#ifdef EXTRA_DEBUG
- if (error && error != EINTR)
+ if (error && error != EINTR && error != ETIMEDOUT)
{
fprintf(stderr, "Got error %d from pthread_cond_timedwait\n",error);
DBUG_PRINT("error",("Got error %d from pthread_cond_timedwait",
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index d670c673b4a..283dd20a56c 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -1042,6 +1042,9 @@ err:
}
send_eof(&thd->net);
+ pthread_mutex_lock(&LOCK_thread_count);
+ thd->current_linfo = 0;
+ pthread_mutex_unlock(&LOCK_thread_count);
DBUG_RETURN(0);
}
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index f870f8f5178..79ba13a3339 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -2631,6 +2631,9 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
join->thd->select_limit)) < 0)
DBUG_RETURN(1); // Impossible range
sel->cond=orig_cond;
+ /* Fix for EXPLAIN */
+ if (sel->quick)
+ join->best_positions[i].records_read= sel->quick->records;
}
else
{
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 0fbb5807c57..1b1b5112e0b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -23,6 +23,7 @@
#endif
#include <hash.h>
#include <myisam.h>
+#include <my_dir.h>
#include <assert.h>
#ifdef __WIN__
@@ -1046,12 +1047,31 @@ static int prepare_for_repair(THD* thd, TABLE_LIST* table,
}
else
{
+ /*
+ User gave us USE_FRM which means that the header in the index file is
+ trashed.
+ In this case we will try to fix the table the following way:
+ - Rename the data file to a temporary name
+ - Truncate the table
+ - Replace the new data file with the old one
+ - Run a normal repair using the new index file and the old data file
+ */
- char from[FN_REFLEN],tmp[FN_REFLEN];
- char* db = thd->db ? thd->db : table->db;
+ char from[FN_REFLEN],tmp[FN_REFLEN+32];
+ const char **ext= table->table->file->bas_ext();
+ MY_STAT stat_info;
+
+ /*
+ Check if this is a table type that stores index and data separately,
+ like ISAM or MyISAM
+ */
+ if (!ext[0] || !ext[1])
+ DBUG_RETURN(0); // No data file
+
+ strxmov(from, table->table->path, ext[1], NullS); // Name of data file
+ if (!my_stat(from, &stat_info, MYF(0)))
+ DBUG_RETURN(0); // Can't use USE_FRM flag
- sprintf(from, "%s/%s/%s", mysql_real_data_home, db, table->real_name);
- fn_format(from, from, "", MI_NAME_DEXT, 4);
sprintf(tmp,"%s-%lx_%lx", from, current_pid, thd->thread_id);
pthread_mutex_lock(&LOCK_open);
@@ -1067,7 +1087,7 @@ static int prepare_for_repair(THD* thd, TABLE_LIST* table,
unlock_table_name(thd, table);
pthread_mutex_unlock(&LOCK_open);
DBUG_RETURN(send_check_errmsg(thd, table, "repair",
- "Failed renaming .MYD file"));
+ "Failed renaming data file"));
}
if (mysql_truncate(thd, table, 1))
{
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index d7a0c15e9b9..f895c809366 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -2310,16 +2310,12 @@ olap_opt:
| WITH CUBE_SYM
{
LEX *lex=Lex;
- lex->olap = true;
- lex->select->olap= CUBE_TYPE;
net_printf(&lex->thd->net, ER_NOT_SUPPORTED_YET, "CUBE");
YYABORT; /* To be deleted in 4.1 */
}
| WITH ROLLUP_SYM
{
LEX *lex=Lex;
- lex->olap = true;
- lex->select->olap= ROLLUP_TYPE;
net_printf(&lex->thd->net, ER_NOT_SUPPORTED_YET, "ROLLUP");
YYABORT; /* To be deleted in 4.1 */
}
@@ -2407,7 +2403,7 @@ delete_limit_clause:
ULONG_NUM:
NUM { $$= strtoul($1.str,NULL,10); }
- | LONG_NUM { $$= (ulonglong) strtoll($1.str,NULL,10); }
+ | LONG_NUM { $$= (ulong) strtoll($1.str,NULL,10); }
| ULONGLONG_NUM { $$= (ulong) strtoull($1.str,NULL,10); }
| REAL_NUM { $$= strtoul($1.str,NULL,10); }
| FLOAT_NUM { $$= strtoul($1.str,NULL,10); };