summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-10-16 03:08:40 +0300
committerunknown <monty@mashka.mysql.fi>2003-10-16 03:08:40 +0300
commitaff45e1b0733947abde48f712c1af64b4f2549a7 (patch)
treebd2eb4ac5dffdd3ac1af40b53a3680a0a9d78195 /sql
parent893797be02d4dff2e1aafbdb98ac4e33b9726628 (diff)
parent0fc97bc9e5c6c0a4f380841b325f6f0647a90bb5 (diff)
downloadmariadb-git-aff45e1b0733947abde48f712c1af64b4f2549a7.tar.gz
merge with 4.0
BitKeeper/deleted/.del-MYSQL.ICO~d93519b5f0d6ee1: Auto merged client/client_priv.h: Auto merged extra/resolveip.c: Auto merged include/mysql.h: Auto merged include/thr_alarm.h: Auto merged myisam/myisamchk.c: Auto merged scripts/mysql_config.sh: Auto merged scripts/mysqld_safe.sh: Auto merged sql/slave.cc: Auto merged sql/sql_class.h: Auto merged sql/sql_handler.cc: Auto merged sql/sql_insert.cc: Auto merged sql/sql_parse.cc: Auto merged sql/sql_test.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/handler.h4
-rw-r--r--sql/mysqld.cc6
-rw-r--r--sql/set_var.cc21
-rw-r--r--sql/slave.cc7
-rw-r--r--sql/sql_class.h3
-rw-r--r--sql/sql_handler.cc15
-rw-r--r--sql/sql_insert.cc13
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_table.cc9
-rw-r--r--sql/sql_test.cc10
10 files changed, 64 insertions, 26 deletions
diff --git a/sql/handler.h b/sql/handler.h
index b756d9a09fb..ad209e5cec9 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -169,10 +169,10 @@ typedef struct st_ha_create_information
SQL_LIST merge_list;
enum db_type db_type;
enum row_type row_type;
- uint options; /* OR of HA_CREATE_ options */
+ uint options; /* OR of HA_CREATE_ options */
uint raid_type,raid_chunks;
uint merge_insert_method;
- bool if_not_exists;
+ bool table_existed; /* 1 in create if table existed */
} HA_CREATE_INFO;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 7b2bfd178e4..812a5b28ff7 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3453,10 +3453,10 @@ error:
Handle start options
******************************************************************************/
-enum options
+enum options_mysqld
{
- OPT_ISAM_LOG=256, OPT_SKIP_NEW,
- OPT_SKIP_GRANT, OPT_SKIP_LOCK,
+ OPT_ISAM_LOG=256, OPT_SKIP_NEW,
+ OPT_SKIP_GRANT, OPT_SKIP_LOCK,
OPT_ENABLE_LOCK, OPT_USE_LOCKING,
OPT_SOCKET, OPT_UPDATE_LOG,
OPT_BIN_LOG, OPT_SKIP_RESOLVE,
diff --git a/sql/set_var.cc b/sql/set_var.cc
index 31ba1fee842..3100c951f68 100644
--- a/sql/set_var.cc
+++ b/sql/set_var.cc
@@ -90,6 +90,7 @@ static void fix_myisam_max_extra_sort_file_size(THD *thd, enum_var_type type);
static void fix_myisam_max_sort_file_size(THD *thd, enum_var_type type);
static void fix_max_binlog_size(THD *thd, enum_var_type type);
static void fix_max_relay_log_size(THD *thd, enum_var_type type);
+static void fix_max_connections(THD *thd, enum_var_type type);
static KEY_CACHE *create_key_cache(const char *name, uint length);
void fix_sql_mode_var(THD *thd, enum_var_type type);
static byte *get_error_count(THD *thd);
@@ -162,7 +163,8 @@ sys_var_long_ptr sys_max_binlog_size("max_binlog_size",
&max_binlog_size,
fix_max_binlog_size);
sys_var_long_ptr sys_max_connections("max_connections",
- &max_connections);
+ &max_connections,
+ fix_max_connections);
sys_var_long_ptr sys_max_connect_errors("max_connect_errors",
&max_connect_errors);
sys_var_long_ptr sys_max_delayed_threads("max_delayed_threads",
@@ -773,7 +775,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type)
thd->options&= ~OPTION_BIG_SELECTS;
}
}
-
+
/*
If one doesn't use the SESSION modifier, the isolation level
@@ -841,7 +843,7 @@ static void fix_query_cache_min_res_unit(THD *thd, enum_var_type type)
#endif
-void fix_delay_key_write(THD *thd, enum_var_type type)
+extern void fix_delay_key_write(THD *thd, enum_var_type type)
{
switch ((enum_delay_key_write) delay_key_write_options) {
case DELAY_KEY_WRITE_NONE:
@@ -857,7 +859,7 @@ void fix_delay_key_write(THD *thd, enum_var_type type)
}
}
-void fix_max_binlog_size(THD *thd, enum_var_type type)
+static void fix_max_binlog_size(THD *thd, enum_var_type type)
{
DBUG_ENTER("fix_max_binlog_size");
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
@@ -870,7 +872,7 @@ void fix_max_binlog_size(THD *thd, enum_var_type type)
DBUG_VOID_RETURN;
}
-void fix_max_relay_log_size(THD *thd, enum_var_type type)
+static void fix_max_relay_log_size(THD *thd, enum_var_type type)
{
DBUG_ENTER("fix_max_relay_log_size");
DBUG_PRINT("info",("max_binlog_size=%lu max_relay_log_size=%lu",
@@ -882,6 +884,13 @@ void fix_max_relay_log_size(THD *thd, enum_var_type type)
DBUG_VOID_RETURN;
}
+#include <thr_alarm.h>
+static void
+fix_max_connections(THD *thd, enum_var_type type)
+{
+ resize_thr_alarm(max_connections);
+}
+
bool sys_var_long_ptr::update(THD *thd, set_var *var)
{
ulonglong tmp= var->value->val_int();
@@ -2076,7 +2085,7 @@ int set_var::check(THD *thd)
{
my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name);
return -1;
- }
+ }
return var->check(thd, this) ? -1 : 0;
}
diff --git a/sql/slave.cc b/sql/slave.cc
index 3e98386bbb1..bb190762855 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1086,11 +1086,12 @@ static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi)
BINLOG_FORMAT_323_GEQ_57 ;
break;
case '4':
- case '5':
mi->old_format = BINLOG_FORMAT_CURRENT;
break;
default:
- errmsg = "Master reported unrecognized MySQL version";
+ /* 5.0 is not supported */
+ errmsg = "Master reported an unrecognized MySQL version. Note that 4.0 \
+slaves can't replicate a 5.0 or newer master.";
break;
}
@@ -3165,6 +3166,8 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \
RPL_LOG_NAME, llstr(rli->group_master_log_pos,llbuff));
err:
+ /* Free temporary tables etc */
+ thd->cleanup();
VOID(pthread_mutex_lock(&LOCK_thread_count));
thd->query = thd->db = 0; // extra safety
VOID(pthread_mutex_unlock(&LOCK_thread_count));
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 304b84dd4e3..f4687a9aa74 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -867,8 +867,7 @@ public:
List<Item> &select_fields,enum_duplicates duplic)
:select_insert (NULL, &select_fields, duplic), db(db_name),
name(table_name), extra_fields(&fields_par),keys(&keys_par),
- create_info(create_info_par),
- lock(0)
+ create_info(create_info_par), lock(0)
{}
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
bool send_data(List<Item> &values);
diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc
index 93ab332bcd5..bce1022d5c0 100644
--- a/sql/sql_handler.cc
+++ b/sql/sql_handler.cc
@@ -33,7 +33,7 @@
The second is to be freeed only on thread end. mysql_ha_open should
then do { handler_items=concat(handler_items, free_list); free_list=0; }
- But !!! do_cammand calls free_root at the end of every query and frees up
+ But !!! do_command calls free_root at the end of every query and frees up
all the sql_alloc'ed memory. It's harder to work around...
*/
@@ -72,7 +72,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok)
if (*ptr)
{
VOID(pthread_mutex_lock(&LOCK_open));
- close_thread_table(thd, ptr);
+ if (close_thread_table(thd, ptr))
+ {
+ /* Tell threads waiting for refresh that something has happened */
+ VOID(pthread_cond_broadcast(&COND_refresh));
+ }
VOID(pthread_mutex_unlock(&LOCK_open));
}
else
@@ -89,8 +93,11 @@ int mysql_ha_close(THD *thd, TABLE_LIST *tables, bool dont_send_ok)
int mysql_ha_closeall(THD *thd, TABLE_LIST *tables)
{
TABLE **ptr=find_table_ptr_by_name(thd, tables->db, tables->real_name, 0);
- if (*ptr)
- close_thread_table(thd, ptr);
+ if (*ptr && close_thread_table(thd, ptr))
+ {
+ /* Tell threads waiting for refresh that something has happened */
+ VOID(pthread_cond_broadcast(&COND_refresh));
+ }
return 0;
}
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index b65245b04c1..9077d4c6a2d 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1553,6 +1553,14 @@ select_create::prepare(List<Item> &values, SELECT_LEX_UNIT *u)
if (!table)
DBUG_RETURN(-1); // abort() deletes table
+ if (table->fields < values.elements)
+ {
+ my_printf_error(ER_WRONG_VALUE_COUNT_ON_ROW,
+ ER(ER_WRONG_VALUE_COUNT_ON_ROW),
+ MYF(0),1);
+ DBUG_RETURN(-1);
+ }
+
/* First field to copy */
field=table->field+table->fields - values.elements;
@@ -1611,7 +1619,7 @@ bool select_create::send_eof()
*/
if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table);
- lock=0;
+ lock=0;
table=0;
VOID(pthread_mutex_unlock(&LOCK_open));
}
@@ -1632,7 +1640,8 @@ void select_create::abort()
enum db_type table_type=table->db_type;
if (!table->tmp_table)
hash_delete(&open_cache,(byte*) table);
- quick_rm_table(table_type,db,name);
+ if (!create_info->table_existed)
+ quick_rm_table(table_type,db,name);
table=0;
}
VOID(pthread_mutex_unlock(&LOCK_open));
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 248dfc0e47a..e8870b20d99 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -3407,7 +3407,7 @@ check_access(THD *thd, ulong want_access, const char *db, ulong *save_priv,
/* grant_option is set if there exists a single table or column grant */
if (db_access == want_access ||
((grant_option && !dont_check_global_grants) &&
- !(want_access & ~TABLE_ACLS)))
+ !(want_access & ~(db_access | TABLE_ACLS))))
DBUG_RETURN(FALSE); /* Ok */
if (!no_errors)
net_printf(thd,ER_DBACCESS_DENIED_ERROR,
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d2f6b508aa4..5417a1b0368 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -901,7 +901,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
&& find_temporary_table(thd,db,table_name))
{
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
+ {
+ create_info->table_existed= 1; // Mark that table existed
DBUG_RETURN(0);
+ }
my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
DBUG_RETURN(-1);
}
@@ -913,14 +916,18 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
if (!access(path,F_OK))
{
if (create_info->options & HA_LEX_CREATE_IF_NOT_EXISTS)
+ {
+ create_info->table_existed= 1; // Mark that table existed
error= 0;
+ }
else
- my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
+ my_error(ER_TABLE_EXISTS_ERROR,MYF(0),table_name);
goto end;
}
}
thd->proc_info="creating table";
+ create_info->table_existed= 0; // Mark that table is created
if (thd->variables.sql_mode & MODE_NO_DIR_IN_CREATE)
create_info->data_file_name= create_info->index_file_name= 0;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 5a2b8ec86e5..112d42e4643 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -301,6 +301,8 @@ void mysql_print_status(THD *thd)
printf("\nStatus information:\n\n");
my_getwd(current_dir, sizeof(current_dir),MYF(0));
printf("Current dir: %s\n", current_dir);
+ printf("Running threads: %d Stack size: %ld\n", thread_count,
+ (long) thread_stack);
if (thd)
thd->proc_info="locks";
thr_print_locks(); // Write some debug info
@@ -379,8 +381,9 @@ Maximum total allocated space: %d\n\
Space available in freed fastbin blocks: %d\n\
Total allocated space: %d\n\
Total free space: %d\n\
-Top-most, releasable space: %d\n",
- (int) info.arena,
+Top-most, releasable space: %d\n\
+Estimated memory (with thread stack): %ld\n",
+ (int) info.arena ,
(int) info.ordblks,
(int) info.smblks,
(int) info.hblks,
@@ -389,7 +392,8 @@ Top-most, releasable space: %d\n",
(int) info.fsmblks,
(int) info.uordblks,
(int) info.fordblks,
- (int) info.keepcost);
+ (int) info.keepcost,
+ (long) (thread_count * thread_stack + info.hblkhd + info.arena));
#endif
puts("");
if (thd)