summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2011-07-02 22:12:12 +0200
committerSergei Golubchik <sergii@pisem.net>2011-07-02 22:12:12 +0200
commitb4a0b2c2f862ab0de853dc34e1e56f6159043e45 (patch)
tree18a0c25fdc9ac0076da19247666414a46434b85e /sql
parent9809f05199aeb0b67991fac41bd86f38730768dc (diff)
downloadmariadb-git-b4a0b2c2f862ab0de853dc34e1e56f6159043e45.tar.gz
post-merge fixes.
most tests pass. 5.3 merge is next
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc2
-rw-r--r--sql/filesort.cc1
-rw-r--r--sql/ha_partition.cc2
-rw-r--r--sql/handler.cc1
-rw-r--r--sql/handler.h13
-rw-r--r--sql/item_cmpfunc.cc2
-rw-r--r--sql/item_create.cc8
-rw-r--r--sql/item_timefunc.cc13
-rw-r--r--sql/log_event.cc14
-rw-r--r--sql/log_event.h2
-rw-r--r--sql/multi_range_read.cc2
-rw-r--r--sql/my_decimal.cc8
-rw-r--r--sql/mysqld.cc39
-rw-r--r--sql/mysqld.h3
-rw-r--r--sql/net_serv.cc80
-rw-r--r--sql/protocol.cc30
-rw-r--r--sql/rpl_filter.cc2
-rw-r--r--sql/scheduler.cc8
-rw-r--r--sql/scheduler.h9
-rw-r--r--sql/sp.cc13
-rw-r--r--sql/sql_acl.cc127
-rw-r--r--sql/sql_analyse.cc10
-rw-r--r--sql/sql_class.cc55
-rw-r--r--sql/sql_class.h2
-rw-r--r--sql/sql_connect.cc2
-rw-r--r--sql/sql_connect.h2
-rw-r--r--sql/sql_delete.cc10
-rw-r--r--sql/sql_parse.cc4
-rw-r--r--sql/sql_partition.h4
-rw-r--r--sql/sql_plugin.cc4
-rw-r--r--sql/sql_select.cc21
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_table.cc2
-rw-r--r--sql/sql_update.cc41
-rw-r--r--sql/sys_vars.cc9
-rw-r--r--sql/table.cc45
36 files changed, 267 insertions, 325 deletions
diff --git a/sql/field.cc b/sql/field.cc
index e6caaf947b1..61786557531 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -10199,7 +10199,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
{
/* DBL_DIG is enough to print '-[digits].E+###' */
char str_nr[DBL_DIG + 8];
- uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr));
+ uint str_len= sprintf(str_nr, "%g", nr);
make_truncated_value_warning(thd, level, str_nr, str_len, ts_type,
field_name);
}
diff --git a/sql/filesort.cc b/sql/filesort.cc
index a70f6cbd2ed..19eba8cc84d 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -30,6 +30,7 @@
#include <m_ctype.h>
#include "sql_sort.h"
#include "probes_mysql.h"
+#include "sql_base.h" // update_virtual_fields
#include "sql_test.h" // TEST_filesort
#include "opt_range.h" // SQL_SELECT
#include "log_slow.h"
diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc
index b35a6cb7bf3..512152f1f57 100644
--- a/sql/ha_partition.cc
+++ b/sql/ha_partition.cc
@@ -1078,7 +1078,7 @@ static bool print_admin_msg(THD* thd, const char* msg_type,
va_list args;
Protocol *protocol= thd->protocol;
uint length, msg_length;
- char msgbuf[HA_MAX_MSG_BUF];
+ char msgbuf[MYSQL_ERRMSG_SIZE];
char name[SAFE_NAME_LEN*2+2];
va_start(args, fmt);
diff --git a/sql/handler.cc b/sql/handler.cc
index 41bac077e3b..5b87420134c 100644
--- a/sql/handler.cc
+++ b/sql/handler.cc
@@ -28,6 +28,7 @@
#include "unireg.h"
#include "rpl_handler.h"
#include "sql_cache.h" // query_cache, query_cache_*
+#include "sql_connect.h" // global_table_stats
#include "key.h" // key_copy, key_unpack, key_cmp_if_same, key_cmp
#include "sql_table.h" // build_table_filename
#include "sql_parse.h" // check_stack_overrun
diff --git a/sql/handler.h b/sql/handler.h
index 8524ecfd695..979d66cdb1f 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1118,7 +1118,7 @@ typedef struct st_ha_create_information
{
CHARSET_INFO *table_charset, *default_table_charset;
LEX_STRING connect_string;
- const char *password;
+ const char *password, *tablespace;
LEX_STRING comment;
const char *data_file_name, *index_file_name;
const char *alias;
@@ -1147,6 +1147,7 @@ typedef struct st_ha_create_information
enum ha_choice transactional;
bool frm_only; ///< 1 if no ha_create_table()
bool varchar; ///< 1 if table has a VARCHAR
+ enum ha_storage_media storage_media; ///< DEFAULT, DISK or MEMORY
enum ha_choice page_checksum; ///< If we have page_checksums
engine_option_value *option_list; ///< list of table create options
/* the following three are only for ALTER TABLE, check_if_incompatible_data() */
@@ -2555,14 +2556,16 @@ private:
@remark The table is locked in exclusive mode.
*/
virtual int truncate()
- { return HA_ERR_WRONG_COMMAND; }
+ {
+ int error= delete_all_rows();
+ return error ? error : reset_auto_increment(0);
+ }
/**
Reset the auto-increment counter to the given value, i.e. the next row
- inserted will get the given value. HA_ERR_WRONG_COMMAND is returned by
- storage engines that don't support this operation.
+ inserted will get the given value.
*/
virtual int reset_auto_increment(ulonglong value)
- { return HA_ERR_WRONG_COMMAND; }
+ { return 0; }
virtual int optimize(THD* thd, HA_CHECK_OPT* check_opt)
{ return HA_ADMIN_NOT_IMPLEMENTED; }
virtual int analyze(THD* thd, HA_CHECK_OPT* check_opt)
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index b0c2dac7b74..b421dddf815 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2042,7 +2042,7 @@ Item *Item_in_optimizer::transform(Item_transformer transformer, uchar *argument
{
Item *new_item;
- DBUG_ASSERT(!current_thd->is_stmt_prepare());
+ DBUG_ASSERT(!current_thd->stmt_arena->is_stmt_prepare());
DBUG_ASSERT(arg_count == 2);
/* Transform the left IN operand. */
diff --git a/sql/item_create.cc b/sql/item_create.cc
index d0f1ab54eca..bc3c904e5fd 100644
--- a/sql/item_create.cc
+++ b/sql/item_create.cc
@@ -1334,7 +1334,7 @@ protected:
class Create_func_like_range_min : public Create_func_arg2
{
public:
- virtual Item *create(THD *thd, Item *arg1, Item *arg2);
+ virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
static Create_func_like_range_min s_singleton;
@@ -1347,7 +1347,7 @@ protected:
class Create_func_like_range_max : public Create_func_arg2
{
public:
- virtual Item *create(THD *thd, Item *arg1, Item *arg2);
+ virtual Item *create_2_arg(THD *thd, Item *arg1, Item *arg2);
static Create_func_like_range_max s_singleton;
@@ -3868,7 +3868,7 @@ Create_func_length::create_1_arg(THD *thd, Item *arg1)
Create_func_like_range_min Create_func_like_range_min::s_singleton;
Item*
-Create_func_like_range_min::create(THD *thd, Item *arg1, Item *arg2)
+Create_func_like_range_min::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_like_range_min(arg1, arg2);
}
@@ -3877,7 +3877,7 @@ Create_func_like_range_min::create(THD *thd, Item *arg1, Item *arg2)
Create_func_like_range_max Create_func_like_range_max::s_singleton;
Item*
-Create_func_like_range_max::create(THD *thd, Item *arg1, Item *arg2)
+Create_func_like_range_max::create_2_arg(THD *thd, Item *arg1, Item *arg2)
{
return new (thd->mem_root) Item_func_like_range_max(arg1, arg2);
}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index d7cd2d459f4..5aa4db219e8 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -776,13 +776,12 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
str->append(hours_i < 12 ? "AM" : "PM",2);
break;
case 'r':
- length= my_sprintf(intbuff,
- (intbuff,
+ length= sprintf(intbuff,
((l_time->hour % 24) < 12) ?
"%02d:%02d:%02d AM" : "%02d:%02d:%02d PM",
(l_time->hour+11)%12+1,
l_time->minute,
- l_time->second));
+ l_time->second);
str->append(intbuff, length);
break;
case 'S':
@@ -791,12 +790,11 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'T':
- length= my_sprintf(intbuff,
- (intbuff,
+ length= sprintf(intbuff,
"%02d:%02d:%02d",
l_time->hour,
l_time->minute,
- l_time->second));
+ l_time->second);
str->append(intbuff, length);
break;
case 'U':
@@ -3135,8 +3133,7 @@ String *Item_func_maketime::val_str(String *str)
ltime.second= TIME_MAX_SECOND;
char buf[28];
char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10);
- int len = (int)(ptr - buf) +
- my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second));
+ int len = (int)(ptr - buf) + sprintf(ptr, ":%02u:%02u", (uint)minute, (uint)second);
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buf, len, MYSQL_TIMESTAMP_TIME,
NullS);
diff --git a/sql/log_event.cc b/sql/log_event.cc
index c5935b86df9..70087ed4da3 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1661,11 +1661,11 @@ log_event_print_value(IO_CACHE *file, const uchar *ptr,
int i, end;
char buff[512], *pos;
pos= buff;
- pos+= my_sprintf(buff, (buff, "%s", dec.sign() ? "-" : ""));
+ pos+= sprintf(buff, "%s", dec.sign() ? "-" : "");
end= ROUND_UP(dec.frac) + ROUND_UP(dec.intg)-1;
for (i=0; i < end; i++)
- pos+= my_sprintf(pos, (pos, "%09d.", dec.buf[i]));
- pos+= my_sprintf(pos, (pos, "%09d", dec.buf[i]));
+ pos+= sprintf(pos, "%09d.", dec.buf[i]);
+ pos+= sprintf(pos, "%09d", dec.buf[i]);
my_b_printf(file, "%s", buff);
my_snprintf(typestr, typestr_length, "DECIMAL(%d,%d)",
precision, decimals);
@@ -6588,9 +6588,7 @@ void Append_block_log_event::pack_info(Protocol *protocol)
{
char buf[256];
uint length;
- length= (uint) my_sprintf(buf,
- (buf, ";file_id=%u;block_len=%u", file_id,
- block_len));
+ length= (uint) sprintf(buf, ";file_id=%u;block_len=%u", file_id, block_len);
protocol->store(buf, length, &my_charset_bin);
}
@@ -6746,7 +6744,7 @@ void Delete_file_log_event::pack_info(Protocol *protocol)
{
char buf[64];
uint length;
- length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id));
+ length= (uint) sprintf(buf, ";file_id=%u", (uint) file_id);
protocol->store(buf, (int32) length, &my_charset_bin);
}
#endif
@@ -6844,7 +6842,7 @@ void Execute_load_log_event::pack_info(Protocol *protocol)
{
char buf[64];
uint length;
- length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id));
+ length= (uint) sprintf(buf, ";file_id=%u", (uint) file_id);
protocol->store(buf, (int32) length, &my_charset_bin);
}
diff --git a/sql/log_event.h b/sql/log_event.h
index e57115432ec..3a54702c2d1 100644
--- a/sql/log_event.h
+++ b/sql/log_event.h
@@ -2194,8 +2194,6 @@ public: /* !!! Public in this patch to allow old usage */
#endif
};
-extern char server_version[SERVER_VERSION_LENGTH];
-
/**
@class Start_log_event_v3
diff --git a/sql/multi_range_read.cc b/sql/multi_range_read.cc
index e539f30d978..b338bc147bc 100644
--- a/sql/multi_range_read.cc
+++ b/sql/multi_range_read.cc
@@ -356,7 +356,7 @@ int DsMrr_impl::dsmrr_init(handler *h_arg, RANGE_SEQ_IF *seq_funcs,
uint mrr_keyno= h->active_index;
/* Create a separate handler object to do rndpos() calls. */
- if (!(new_h2= h->clone(thd->mem_root)) ||
+ if (!(new_h2= h->clone(h->table->s->normalized_path.str, thd->mem_root)) ||
new_h2->ha_external_lock(thd, F_RDLCK))
{
delete new_h2;
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 318cdfd10c4..16449da701f 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -307,12 +307,12 @@ print_decimal(const my_decimal *dec)
int i, end;
char buff[512], *pos;
pos= buff;
- pos+= my_sprintf(buff, (buff, "Decimal: sign: %d intg: %d frac: %d { ",
- dec->sign(), dec->intg, dec->frac));
+ pos+= sprintf(buff, "Decimal: sign: %d intg: %d frac: %d { ",
+ dec->sign(), dec->intg, dec->frac);
end= ROUND_UP(dec->frac)+ROUND_UP(dec->intg)-1;
for (i=0; i < end; i++)
- pos+= my_sprintf(pos, (pos, "%09d, ", dec->buf[i]));
- pos+= my_sprintf(pos, (pos, "%09d }\n", dec->buf[i]));
+ pos+= sprintf(pos, "%09d, ", dec->buf[i]);
+ pos+= sprintf(pos, "%09d }\n", dec->buf[i]);
fputs(buff, DBUG_FILE);
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 61f6c55bbdf..49912b6fa9e 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -927,7 +927,9 @@ my_bool opt_use_ssl = 0;
char *opt_ssl_ca= NULL, *opt_ssl_capath= NULL, *opt_ssl_cert= NULL,
*opt_ssl_cipher= NULL, *opt_ssl_key= NULL;
-scheduler_functions thread_scheduler, extra_thread_scheduler;
+static scheduler_functions thread_scheduler_struct, extra_thread_scheduler_struct;
+scheduler_functions *thread_scheduler= &thread_scheduler_struct,
+ *extra_thread_scheduler= &extra_thread_scheduler_struct;
#ifdef HAVE_OPENSSL
#include <openssl/crypto.h>
@@ -1119,7 +1121,7 @@ static void close_connections(void)
continue;
tmp->killed= THD::KILL_CONNECTION;
- MYSQL_CALLBACK(&thread_scheduler, post_kill_notification, (tmp));
+ MYSQL_CALLBACK(thread_scheduler, post_kill_notification, (tmp));
mysql_mutex_lock(&tmp->LOCK_thd_data);
if (tmp->mysys_var)
{
@@ -1544,7 +1546,7 @@ void clean_up(bool print_message)
if (print_message && my_default_lc_messages && server_start_time)
sql_print_information(ER_DEFAULT(ER_SHUTDOWN_COMPLETE),my_progname);
cleanup_errmsgs();
- MYSQL_CALLBACK(&thread_scheduler, end, ());
+ MYSQL_CALLBACK(thread_scheduler, end, ());
mysql_library_end();
finish_client_errs();
(void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs
@@ -1585,7 +1587,10 @@ static void wait_for_signal_thread_to_end()
for (i= 0 ; i < 100 && signal_thread_in_use; i++)
{
if (pthread_kill(signal_thread, MYSQL_KILL_SIGNAL) != ESRCH)
+ {
+ fprintf(stderr, "signal thread appears to be dead\n");
break;
+ }
my_sleep(100); // Give it time to die
}
}
@@ -1950,7 +1955,7 @@ static void network_init(void)
int arg;
DBUG_ENTER("network_init");
- if (MYSQL_CALLBACK_ELSE(&thread_scheduler, init, (), 0))
+ if (MYSQL_CALLBACK_ELSE(thread_scheduler, init, (), 0))
unireg_abort(1); /* purecov: inspected */
set_ports();
@@ -2125,7 +2130,7 @@ void thd_cleanup(THD *thd)
dec_connection_count()
*/
-void dec_connection_count()
+void dec_connection_count(THD *thd)
{
mysql_mutex_lock(&LOCK_connection_count);
(*thd->scheduler->connection_count)--;
@@ -2165,7 +2170,7 @@ void unlink_thd(THD *thd)
DBUG_PRINT("enter", ("thd: 0x%lx", (long) thd));
thd_cleanup(thd);
- dec_connection_count();
+ dec_connection_count(thd);
mysql_mutex_lock(&LOCK_thread_count);
/*
Used by binlog_reset_master. It would be cleaner to use
@@ -2545,7 +2550,7 @@ and this may fail.\n\n");
(ulong) dflt_key_cache->key_cache_mem_size);
fprintf(stderr, "read_buffer_size=%ld\n", (long) global_system_variables.read_buff_size);
fprintf(stderr, "max_used_connections=%lu\n", max_used_connections);
- fprintf(stderr, "max_threads=%u\n", thread_scheduler.max_threads +
+ fprintf(stderr, "max_threads=%u\n", thread_scheduler->max_threads +
(uint) extra_max_connections);
fprintf(stderr, "thread_count=%u\n", thread_count);
fprintf(stderr, "It is possible that mysqld could use up to \n\
@@ -2553,7 +2558,7 @@ key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = %lu K\n\
bytes of memory\n", ((ulong) dflt_key_cache->key_cache_mem_size +
(global_system_variables.read_buff_size +
global_system_variables.sortbuff_size) *
- (thread_scheduler.max_threads + extra_max_connections) +
+ (thread_scheduler->max_threads + extra_max_connections) +
(max_connections + extra_max_connections)* sizeof(THD)) / 1024);
fprintf(stderr, "Hope that's ok; if not, decrease some variables in the equation.\n\n");
@@ -2805,7 +2810,7 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
This should actually be '+ max_number_of_slaves' instead of +10,
but the +10 should be quite safe.
*/
- init_thr_alarm(thread_scheduler.max_threads + extra_max_connections +
+ init_thr_alarm(thread_scheduler->max_threads + extra_max_connections +
global_system_variables.max_insert_delayed_threads + 10);
if (test_flags & TEST_SIGINT)
{
@@ -2855,8 +2860,8 @@ pthread_handler_t signal_hand(void *arg __attribute__((unused)))
{
DBUG_PRINT("quit",("signal_handler: calling my_thread_end()"));
my_thread_end();
- signal_thread_in_use= 0;
DBUG_LEAVE; // Must match DBUG_ENTER()
+ signal_thread_in_use= 0;
pthread_exit(0); // Safety
return 0; // Avoid compiler warnings
}
@@ -5499,7 +5504,7 @@ void handle_connections_sockets()
if (sock == extra_ip_sock)
{
thd->extra_port= 1;
- thd->scheduler= &extra_thread_scheduler;
+ thd->scheduler= extra_thread_scheduler;
}
create_new_thread(thd);
}
@@ -7637,17 +7642,17 @@ static int get_options(int *argc_ptr, char ***argv_ptr)
return 1;
#ifdef EMBEDDED_LIBRARY
- one_thread_scheduler(&thread_scheduler);
- one_thread_scheduler(&extra_thread_scheduler);
+ one_thread_scheduler(thread_scheduler);
+ one_thread_scheduler(extra_thread_scheduler);
#else
if (thread_handling <= SCHEDULER_ONE_THREAD_PER_CONNECTION)
- one_thread_per_connection_scheduler(&thread_scheduler, &max_connections,
+ one_thread_per_connection_scheduler(thread_scheduler, &max_connections,
&connection_count);
else if (thread_handling == SCHEDULER_NO_THREADS)
- one_thread_scheduler(&thread_scheduler);
+ one_thread_scheduler(thread_scheduler);
else
- pool_of_threads_scheduler(&thread_scheduler); /* purecov: tested */
- one_thread_per_connection_scheduler(&extra_thread_scheduler,
+ pool_of_threads_scheduler(thread_scheduler); /* purecov: tested */
+ one_thread_per_connection_scheduler(extra_thread_scheduler,
&extra_max_connections,
&extra_connection_count);
#endif
diff --git a/sql/mysqld.h b/sql/mysqld.h
index 4ede06f09a6..c23745d9d38 100644
--- a/sql/mysqld.h
+++ b/sql/mysqld.h
@@ -349,6 +349,7 @@ extern char *opt_ssl_ca, *opt_ssl_capath, *opt_ssl_cert, *opt_ssl_cipher,
extern MYSQL_PLUGIN_IMPORT pthread_key(THD*, THR_THD);
#ifdef MYSQL_SERVER
+
/**
only options that need special treatment in get_one_option() deserve
to be listed below
@@ -527,5 +528,5 @@ extern uint mysqld_extra_port;
extern ulong extra_max_connections;
extern ulonglong denied_connections;
extern ulong thread_created;
-extern scheduler_functions thread_scheduler, extra_thread_scheduler;
+extern scheduler_functions *thread_scheduler, *extra_thread_scheduler;
#endif /* MYSQLD_INCLUDED */
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 974bc122d14..c8a839571ee 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -51,6 +51,22 @@
#define MYSQL_CLIENT
#endif /*EMBEDDED_LIBRARY */
+/*
+ to reduce the number of ifdef's in the code
+*/
+#ifdef EXTRA_DEBUG
+#define EXTRA_DEBUG_fprintf fprintf
+#define EXTRA_DEBUG_fflush fflush
+#else
+static void inline EXTRA_DEBUG_fprintf(...) {}
+static int EXTRA_DEBUG_fflush(...) {}
+#endif
+#ifdef MYSQL_SERVER
+#define MYSQL_SERVER_my_error my_error
+#else
+static void inline MYSQL_SERVER_my_error(...) {}
+#endif
+
/*
The following handles the differences when this is linked between the
@@ -164,9 +180,7 @@ my_bool net_realloc(NET *net, size_t length)
/* @todo: 1 and 2 codes are identical. */
net->error= 1;
net->last_errno= ER_NET_PACKET_TOO_LARGE;
-#ifdef MYSQL_SERVER
- my_error(ER_NET_PACKET_TOO_LARGE, MYF(0));
-#endif
+ MYSQL_SERVER_my_error(ER_NET_PACKET_TOO_LARGE, MYF(0));
DBUG_RETURN(1);
}
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
@@ -288,10 +302,8 @@ void net_clear(NET *net, my_bool clear_buffer __attribute__((unused)))
{
DBUG_PRINT("info",("skipped %ld bytes from file: %s",
(long) count, vio_description(net->vio)));
-#if defined(EXTRA_DEBUG)
- fprintf(stderr,"Note: net_clear() skipped %ld bytes from file: %s\n",
+ EXTRA_DEBUG_fprintf(stderr,"Note: net_clear() skipped %ld bytes from file: %s\n",
(long) count, vio_description(net->vio));
-#endif
}
else
{
@@ -640,16 +652,12 @@ net_real_write(NET *net,const uchar *packet, size_t len)
{
if (vio_should_retry(net->vio) && retry_count++ < net->retry_count)
continue;
-#ifdef EXTRA_DEBUG
- fprintf(stderr,
+ EXTRA_DEBUG_fprintf(stderr,
"%s: my_net_write: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
-#endif /* EXTRA_DEBUG */
net->error= 2; /* Close socket */
net->last_errno= ER_NET_PACKET_TOO_LARGE;
-#ifdef MYSQL_SERVER
- my_error(ER_NET_PACKET_TOO_LARGE, MYF(0));
-#endif
+ MYSQL_SERVER_my_error(ER_NET_PACKET_TOO_LARGE, MYF(0));
goto end;
}
retry_count=0;
@@ -663,24 +671,20 @@ net_real_write(NET *net,const uchar *packet, size_t len)
{
if (retry_count++ < net->retry_count)
continue;
-#ifdef EXTRA_DEBUG
- fprintf(stderr, "%s: write looped, aborting thread\n",
+ EXTRA_DEBUG_fprintf(stderr, "%s: write looped, aborting thread\n",
my_progname);
-#endif /* EXTRA_DEBUG */
}
-#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
+#ifndef MYSQL_SERVER
if (vio_errno(net->vio) == SOCKET_EINTR)
{
DBUG_PRINT("warning",("Interrupted write. Retrying..."));
continue;
}
-#endif /* defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER) */
+#endif /* !defined(MYSQL_SERVER) */
net->error= 2; /* Close socket */
net->last_errno= (interrupted ? ER_NET_WRITE_INTERRUPTED :
ER_NET_ERROR_ON_WRITE);
-#ifdef MYSQL_SERVER
- my_error(net->last_errno, MYF(0));
-#endif /* MYSQL_SERVER */
+ MYSQL_SERVER_my_error(net->last_errno, MYF(0));
break;
}
pos+=length;
@@ -840,7 +844,7 @@ my_real_read(NET *net, size_t *complen)
#if !defined(__WIN__) || defined(MYSQL_SERVER)
/*
We got an error that there was no data on the socket. We now set up
- an alarm to not 'read forever', change the socket to non blocking
+ an alarm to not 'read forever', change the socket to the blocking
mode and try again
*/
if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed))
@@ -856,17 +860,13 @@ my_real_read(NET *net, size_t *complen)
DBUG_PRINT("error",
("fcntl returned error %d, aborting thread",
vio_errno(net->vio)));
-#ifdef EXTRA_DEBUG
- fprintf(stderr,
+ EXTRA_DEBUG_fprintf(stderr,
"%s: read: fcntl returned error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
-#endif /* EXTRA_DEBUG */
len= packet_error;
net->error= 2; /* Close socket */
net->last_errno= ER_NET_FCNTL_ERROR;
-#ifdef MYSQL_SERVER
- my_error(ER_NET_FCNTL_ERROR, MYF(0));
-#endif
+ MYSQL_SERVER_my_error(ER_NET_FCNTL_ERROR, MYF(0));
goto end;
}
retry_count=0;
@@ -879,12 +879,10 @@ my_real_read(NET *net, size_t *complen)
{ /* Probably in MIT threads */
if (retry_count++ < net->retry_count)
continue;
-#ifdef EXTRA_DEBUG
- fprintf(stderr, "%s: read looped with error %d, aborting thread\n",
+ EXTRA_DEBUG_fprintf(stderr, "%s: read looped with error %d, aborting thread\n",
my_progname,vio_errno(net->vio));
-#endif /* EXTRA_DEBUG */
}
-#if defined(THREAD_SAFE_CLIENT) && !defined(MYSQL_SERVER)
+#ifndef MYSQL_SERVER
if (vio_errno(net->vio) == SOCKET_EINTR)
{
DBUG_PRINT("warning",("Interrupted read. Retrying..."));
@@ -898,9 +896,7 @@ my_real_read(NET *net, size_t *complen)
net->last_errno= (vio_was_interrupted(net->vio) ?
ER_NET_READ_INTERRUPTED :
ER_NET_READ_ERROR);
-#ifdef MYSQL_SERVER
- my_error(net->last_errno, MYF(0));
-#endif
+ MYSQL_SERVER_my_error(net->last_errno, MYF(0));
goto end;
}
remain -= (uint32) length;
@@ -926,19 +922,17 @@ my_real_read(NET *net, size_t *complen)
the server expects the client to send a file, but the client
may reply with a new command instead.
*/
-#if defined (EXTRA_DEBUG) && !defined (MYSQL_SERVER)
- fflush(stdout);
- fprintf(stderr,"Error: Packets out of order (Found: %d, expected %d)\n",
+#ifndef MYSQL_SERVER
+ EXTRA_DEBUG_fflush(stdout);
+ EXTRA_DEBUG_fprintf(stderr,"Error: Packets out of order (Found: %d, expected %d)\n",
(int) net->buff[net->where_b + 3],
(uint) (uchar) net->pkt_nr);
- fflush(stderr);
+ EXTRA_DEBUG_fflush(stderr);
#endif
}
len= packet_error;
/* Not a NET error on the client. XXX: why? */
-#ifdef MYSQL_SERVER
- my_error(ER_NET_PACKETS_OUT_OF_ORDER, MYF(0));
-#endif
+ MYSQL_SERVER_my_error(ER_NET_PACKETS_OUT_OF_ORDER, MYF(0));
goto end;
}
net->compress_pkt_nr= ++net->pkt_nr;
@@ -1138,9 +1132,7 @@ my_net_read(NET *net)
{
net->error= 2; /* caller will close socket */
net->last_errno= ER_NET_UNCOMPRESS_ERROR;
-#ifdef MYSQL_SERVER
- my_error(ER_NET_UNCOMPRESS_ERROR, MYF(0));
-#endif
+ MYSQL_SERVER_my_error(ER_NET_UNCOMPRESS_ERROR, MYF(0));
MYSQL_NET_READ_DONE(1, 0);
return packet_error;
}
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 0c68df91121..c5937cee807 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -1137,16 +1137,16 @@ bool Protocol_text::store(MYSQL_TIME *tm)
#endif
char buff[40];
uint length;
- length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d",
- (int) tm->year,
- (int) tm->month,
- (int) tm->day,
- (int) tm->hour,
- (int) tm->minute,
- (int) tm->second));
+ length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
+ (int) tm->year,
+ (int) tm->month,
+ (int) tm->day,
+ (int) tm->hour,
+ (int) tm->minute,
+ (int) tm->second);
if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d",
- (int)tm->second_part));
+ length+= sprintf(buff+length, ".%06d",
+ (int)tm->second_part);
return net_store_data((uchar*) buff, length);
}
@@ -1180,13 +1180,13 @@ bool Protocol_text::store_time(MYSQL_TIME *tm)
char buff[40];
uint length;
uint day= (tm->year || tm->month) ? 0 : tm->day;
- length= my_sprintf(buff,(buff, "%s%02ld:%02d:%02d",
- tm->neg ? "-" : "",
- (long) day*24L+(long) tm->hour,
- (int) tm->minute,
- (int) tm->second));
+ length= sprintf(buff, "%s%02ld:%02d:%02d",
+ tm->neg ? "-" : "",
+ (long) day*24L+(long) tm->hour,
+ (int) tm->minute,
+ (int) tm->second);
if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part));
+ length+= sprintf(buff+length, ".%06d", (int)tm->second_part);
return net_store_data((uchar*) buff, length);
}
diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc
index 1f0b752c8c8..a8ed9cfffe0 100644
--- a/sql/rpl_filter.cc
+++ b/sql/rpl_filter.cc
@@ -14,7 +14,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "sql_priv.h"
-//#include "unireg.h" // REQUIRED by other includes
+#include "mysqld.h" // system_charset_info
#include "rpl_filter.h"
#include "hash.h" // my_hash_free
#include "table.h" // TABLE_LIST
diff --git a/sql/scheduler.cc b/sql/scheduler.cc
index b1083083c38..df1fc68dddc 100644
--- a/sql/scheduler.cc
+++ b/sql/scheduler.cc
@@ -21,13 +21,11 @@
#pragma implementation
#endif
-#include <sql_priv.h>
-#include "unireg.h" // REQUIRED: for other includes
-#include "scheduler.h"
#include "sql_connect.h" // init_new_connection_handler_thread
#include "scheduler.h"
+#include "mysqld.h"
+#include "sql_class.h"
#include "sql_callback.h"
-#include "sql_audit.h"
/*
End connection, in case when we are using 'no-threads'
@@ -51,7 +49,7 @@ extern "C"
static void scheduler_wait_lock_begin(void) {
THD *thd=current_thd;
scheduler_functions *func= thd->scheduler;
- MYSQL_CALLBACK(func, thd_wait_begin, (thd, THD_WAIT_ROW_TABLE_LOCK));
+ MYSQL_CALLBACK(func, thd_wait_begin, (thd, THD_WAIT_TABLE_LOCK));
}
static void scheduler_wait_lock_end(void) {
diff --git a/sql/scheduler.h b/sql/scheduler.h
index 247c98515ac..7c9cafd8a71 100644
--- a/sql/scheduler.h
+++ b/sql/scheduler.h
@@ -24,6 +24,8 @@
#pragma interface
#endif
+#include <my_global.h>
+
class THD;
/* Functions used when manipulating threads */
@@ -119,11 +121,4 @@ class thd_scheduler
#endif
-void *thd_get_scheduler_data(THD *thd);
-void thd_set_scheduler_data(THD *thd, void *data);
-PSI_thread* thd_get_psi(THD *thd);
-void thd_set_psi(THD *thd, PSI_thread *psi);
-
-extern scheduler_functions *thread_scheduler;
-
#endif
diff --git a/sql/sp.cc b/sql/sp.cc
index 283db3539c9..982dc3dc91b 100644
--- a/sql/sp.cc
+++ b/sql/sp.cc
@@ -1400,6 +1400,7 @@ bool lock_db_routines(THD *thd, char *db)
Open_tables_backup open_tables_state_backup;
MDL_request_list mdl_requests;
Lock_db_routines_error_handler err_handler;
+ uchar keybuf[MAX_KEY_LENGTH];
DBUG_ENTER("lock_db_routines");
/*
@@ -1422,11 +1423,11 @@ bool lock_db_routines(THD *thd, char *db)
table->field[MYSQL_PROC_FIELD_DB]->store(db, strlen(db), system_charset_info);
key_len= table->key_info->key_part[0].store_length;
+ table->field[MYSQL_PROC_FIELD_DB]->get_key_image(keybuf, key_len, Field::itRAW);
table->file->ha_index_init(0, 1);
- if (! table->file->index_read_map(table->record[0],
- table->field[MYSQL_PROC_FIELD_DB]->ptr,
- (key_part_map)1, HA_READ_KEY_EXACT))
+ if (! table->file->ha_index_read_map(table->record[0], keybuf, (key_part_map)1,
+ HA_READ_KEY_EXACT))
{
do
{
@@ -1438,9 +1439,7 @@ bool lock_db_routines(THD *thd, char *db)
MDL_key::FUNCTION : MDL_key::PROCEDURE,
db, sp_name, MDL_EXCLUSIVE, MDL_TRANSACTION);
mdl_requests.push_front(mdl_request);
- } while (! (nxtres= table->file->index_next_same(table->record[0],
- table->field[MYSQL_PROC_FIELD_DB]->ptr,
- key_len)));
+ } while (! (nxtres= table->file->ha_index_next_same(table->record[0], keybuf, key_len)));
}
table->file->ha_index_end();
if (nxtres != 0 && nxtres != HA_ERR_END_OF_FILE)
@@ -1487,8 +1486,6 @@ sp_drop_db_routines(THD *thd, char *db)
key_len= table->key_info->key_part[0].store_length;
table->field[MYSQL_PROC_FIELD_DB]->get_key_image(keybuf, key_len, Field::itRAW);
-
-
ret= SP_OK;
table->file->ha_index_init(0, 1);
if (!table->file->ha_index_read_map(table->record[0], keybuf, (key_part_map)1,
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 77c467b7dcf..c800f4c6bac 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -611,6 +611,7 @@ static char *fix_plugin_ptr(char *name)
*/
static bool fix_user_plugin_ptr(ACL_USER *user)
{
+ user->salt_len= 0;
if (my_strcasecmp(system_charset_info, user->plugin.str,
native_password_plugin_name.str) == 0)
user->plugin= native_password_plugin_name;
@@ -706,13 +707,6 @@ set_user_plugin (ACL_USER *user, int password_len)
case SCRAMBLED_PASSWORD_CHAR_LENGTH_323:
user->plugin= old_password_plugin_name;
return FALSE;
- case 45: /* 4.1: to be removed */
- sql_print_warning("Found 4.1.0 style password for user '%s@%s'. "
- "Ignoring user. "
- "You should change password for this user.",
- user->user ? user->user : "",
- user->host.hostname ? user->host.hostname : "");
- return TRUE;
default:
sql_print_warning("Found invalid password for user: '%s@%s'; "
"Ignoring user", user->user ? user->user : "",
@@ -1468,15 +1462,14 @@ static void acl_update_user(const char *user, const char *host,
if (fix_user_plugin_ptr(acl_user))
acl_user->plugin.str= strmake_root(&mem, plugin->str, plugin->length);
}
-#if 0
else
- if (password)
+ if (password[0])
{
acl_user->auth_string.str= strmake_root(&mem, password, password_len);
acl_user->auth_string.length= password_len;
set_user_salt(acl_user, password, password_len);
+ set_user_plugin(acl_user, password_len);
}
-#endif
acl_user->access=privileges;
if (mqh->specified_limits & USER_RESOURCES::QUERIES_PER_HOUR)
acl_user->user_resource.questions=mqh->questions;
@@ -1496,8 +1489,6 @@ 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)
- set_user_salt(acl_user, password, password_len);
/* search complete: */
break;
}
@@ -1534,10 +1525,10 @@ static void acl_insert_user(const char *user, const char *host,
}
else
{
- acl_user.plugin= password_len == SCRAMBLED_PASSWORD_CHAR_LENGTH_323 ?
- old_password_plugin_name : native_password_plugin_name;
acl_user.auth_string.str= strmake_root(&mem, password, password_len);
acl_user.auth_string.length= password_len;
+ set_user_salt(&acl_user, password, password_len);
+ set_user_plugin(&acl_user, password_len);
}
acl_user.access=privileges;
@@ -1550,8 +1541,6 @@ static void acl_insert_user(const char *user, const char *host,
acl_user.x509_issuer= x509_issuer ? strdup_root(&mem,x509_issuer) : 0;
acl_user.x509_subject=x509_subject ? strdup_root(&mem,x509_subject) : 0;
- set_user_salt(&acl_user, password, password_len);
-
(void) push_dynamic(&acl_users,(uchar*) &acl_user);
if (!acl_user.host.hostname ||
(acl_user.host.hostname[0] == wild_many && !acl_user.host.hostname[1]))
@@ -1965,11 +1954,10 @@ bool change_password(THD *thd, const char *host, const char *user,
if (mysql_bin_log.is_open())
{
query_length=
- my_sprintf(buff,
- (buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
- acl_user->user ? acl_user->user : "",
- acl_user->host.hostname ? acl_user->host.hostname : "",
- new_password));
+ sprintf(buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
+ acl_user->user ? acl_user->user : "",
+ acl_user->host.hostname ? acl_user->host.hostname : "",
+ new_password);
thd->clear_error();
result= thd->binlog_query(THD::STMT_QUERY_TYPE, buff, query_length,
FALSE, FALSE, FALSE, 0);
@@ -2272,14 +2260,12 @@ static bool test_if_create_new_users(THD *thd)
Handle GRANT commands
****************************************************************************/
-static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
+static int replace_user_table(THD *thd, TABLE *table, LEX_USER &combo,
ulong rights, bool revoke_grant,
bool can_create_user, bool no_auto_create)
{
int error = -1;
bool old_row_exists=0;
- const char *password= "";
- uint password_len= 0;
char what= (revoke_grant) ? 'N' : 'Y';
uchar user_key[MAX_KEY_LENGTH];
LEX *lex= thd->lex;
@@ -2295,9 +2281,9 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
my_error(ER_PASSWD_LENGTH, MYF(0), SCRAMBLED_PASSWORD_CHAR_LENGTH);
DBUG_RETURN(-1);
}
- password_len= combo.password.length;
- password=combo.password.str;
}
+ else
+ combo.password= empty_lex_str;
table->use_all_columns();
table->field[0]->store(combo.host.str,combo.host.length,
@@ -2330,7 +2316,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
see also test_if_create_new_users()
*/
- else if (!password_len && !combo.plugin.length && no_auto_create)
+ else if (!combo.password.length && !combo.plugin.length && no_auto_create)
{
my_error(ER_PASSWORD_NO_MATCH, MYF(0));
goto end;
@@ -2355,30 +2341,11 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
system_charset_info);
table->field[1]->store(combo.user.str,combo.user.length,
system_charset_info);
- table->field[2]->store(password, password_len,
- system_charset_info);
}
else
{
old_row_exists = 1;
store_record(table,record[1]); // Save copy for update
-#if 0
- /* what == 'N' means revoke */
- if (combo.plugin.length && what != 'N')
- {
- my_error(ER_GRANT_PLUGIN_USER_EXISTS, MYF(0),
- static_cast<int>(combo.user.length), combo.user.str);
- goto end;
- }
-#endif
- if (combo.password.str) // If password given
- table->field[2]->store(password, password_len, system_charset_info);
- else if (!rights && !revoke_grant &&
- lex->ssl_type == SSL_TYPE_NOT_SPECIFIED &&
- !lex->mqh.specified_limits)
- {
- DBUG_RETURN(0);
- }
}
/* Update table columns with new privileges */
@@ -2396,6 +2363,8 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
}
rights= get_access(table, 3, &next_field);
DBUG_PRINT("info",("table fields: %d",table->s->fields));
+ if (combo.password.str[0])
+ table->field[2]->store(combo.password.str, combo.password.length, system_charset_info);
if (table->s->fields >= 31) /* From 4.0.0 we have more fields */
{
/* We write down SSL related ACL stuff */
@@ -2454,14 +2423,25 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo,
mqh_used= mqh_used || mqh.questions || mqh.updates || mqh.conn_per_hour;
next_field+= 4;
- if (table->s->fields >= 41 && combo.plugin.str[0])
+ if (table->s->fields >= 41)
{
- table->field[next_field]->store(combo.plugin.str, combo.plugin.length,
- system_charset_info);
table->field[next_field]->set_notnull();
- table->field[next_field + 1]->store(combo.auth.str, combo.auth.length,
- system_charset_info);
table->field[next_field + 1]->set_notnull();
+ if (combo.plugin.str[0])
+ {
+ DBUG_ASSERT(combo.password.str[0] == 0);
+ table->field[2]->reset();
+ table->field[next_field]->store(combo.plugin.str, combo.plugin.length,
+ system_charset_info);
+ table->field[next_field + 1]->store(combo.auth.str, combo.auth.length,
+ system_charset_info);
+ }
+ if (combo.password.str[0])
+ {
+ DBUG_ASSERT(combo.plugin.str[0] == 0);
+ table->field[next_field]->reset();
+ table->field[next_field + 1]->reset();
+ }
}
}
@@ -2502,7 +2482,7 @@ end:
acl_cache->clear(1); // Clear privilege cache
if (old_row_exists)
acl_update_user(combo.user.str, combo.host.str,
- combo.password.str, password_len,
+ combo.password.str, combo.password.length,
lex->ssl_type,
lex->ssl_cipher,
lex->x509_issuer,
@@ -2512,7 +2492,8 @@ end:
&combo.plugin,
&combo.auth);
else
- acl_insert_user(combo.user.str, combo.host.str, password, password_len,
+ acl_insert_user(combo.user.str, combo.host.str,
+ combo.password.str, combo.password.length,
lex->ssl_type,
lex->ssl_cipher,
lex->x509_issuer,
@@ -2714,9 +2695,9 @@ replace_proxies_priv_table(THD *thd, TABLE *table, const LEX_USER *user,
get_grantor(thd, grantor);
table->file->ha_index_init(0, 1);
- if (table->file->index_read_map(table->record[0], user_key,
- HA_WHOLE_KEY,
- HA_READ_KEY_EXACT))
+ if (table->file->ha_index_read_map(table->record[0], user_key,
+ HA_WHOLE_KEY,
+ HA_READ_KEY_EXACT))
{
DBUG_PRINT ("info", ("Row not found"));
if (revoke_grant)
@@ -7909,7 +7890,7 @@ struct MPVIO_EXT :public MYSQL_PLUGIN_VIO
{
MYSQL_SERVER_AUTH_INFO auth_info;
THD *thd;
- const ACL_USER *acl_user; ///< a copy, independent from acl_users array
+ ACL_USER *acl_user; ///< a copy, independent from acl_users array
plugin_ref plugin; ///< what plugin we're under
LEX_STRING db; ///< db name from the handshake packet
/** when restarting a plugin this caches the last client reply */
@@ -8140,8 +8121,6 @@ static bool send_plugin_request_packet(MPVIO_EXT *mpvio,
((st_mysql_auth *) (plugin_decl(mpvio->plugin)->info))->client_auth_plugin;
DBUG_ASSERT(client_auth_plugin);
- DBUG_ASSERT(my_strcasecmp(system_charset_info, client_auth_plugin,
- mpvio->cached_client_reply.plugin));
/*
we send an old "short 4.0 scramble request", if we need to request a
@@ -8238,7 +8217,7 @@ static bool find_mpvio_user(MPVIO_EXT *mpvio)
}
mpvio->auth_info.user_name= sctx->user;
- mpvio->auth_info.user_name_length= user_len;
+ mpvio->auth_info.user_name_length= strlen(sctx->user);
mpvio->auth_info.auth_string= mpvio->acl_user->auth_string.str;
mpvio->auth_info.auth_string_length=
(unsigned long) mpvio->acl_user->auth_string.length;
@@ -8424,7 +8403,7 @@ static ulong parse_client_handshake_packet(MPVIO_EXT *mpvio,
}
else
{
- mpvio->max_client_packet_length= uint3korr(net->read_pos + 2);
+ thd->max_client_packet_length= uint3korr(net->read_pos + 2);
end= (char*) net->read_pos + 5;
}
@@ -8757,7 +8736,7 @@ static int server_mpvio_read_packet(MYSQL_PLUGIN_VIO *param, uchar **buf)
err:
if (mpvio->status == MPVIO_EXT::FAILURE)
{
- inc_host_errors(mpvio->thd->security_ctx.ip);
+ inc_host_errors(mpvio->thd->security_ctx->ip);
if (!mpvio->thd->is_error())
my_error(ER_HANDSHAKE_ERROR, MYF(0));
}
@@ -8964,6 +8943,9 @@ bool acl_authenticate(THD *thd, uint connect_errors,
mpvio.thd= thd;
mpvio.connect_errors= connect_errors;
mpvio.status= MPVIO_EXT::FAILURE;
+ mpvio.auth_info.host_or_ip= thd->security_ctx->host_or_ip;
+ mpvio.auth_info.host_or_ip_length=
+ (unsigned int) strlen(thd->security_ctx->host_or_ip);
DBUG_PRINT("info", ("com_change_user_pkt_len=%u", com_change_user_pkt_len));
@@ -9062,7 +9044,7 @@ bool acl_authenticate(THD *thd, uint connect_errors,
if (!proxy_user)
{
if (!thd->is_error())
- login_failed_error(&mpvio, mpvio.auth_info.password_used);
+ login_failed_error(thd, mpvio.auth_info.password_used);
DBUG_RETURN(1);
}
@@ -9078,7 +9060,7 @@ bool acl_authenticate(THD *thd, uint connect_errors,
if (!acl_proxy_user)
{
if (!thd->is_error())
- login_failed_error(&mpvio, mpvio.auth_info.password_used);
+ login_failed_error(thd, mpvio.auth_info.password_used);
mysql_mutex_unlock(&acl_cache->lock);
DBUG_RETURN(1);
}
@@ -9266,7 +9248,12 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio,
#endif
if (pkt_len == 0) /* no password */
- DBUG_RETURN(info->auth_string[0] ? CR_ERROR : CR_OK);
+ {
+ if (info->auth_string[0])
+ DBUG_RETURN(CR_ERROR);
+ else
+ DBUG_RETURN(CR_OK);
+ }
info->password_used= PASSWORD_USED_YES;
if (pkt_len == SCRAMBLE_LENGTH)
@@ -9274,11 +9261,13 @@ static int native_password_authenticate(MYSQL_PLUGIN_VIO *vio,
if (!mpvio->acl_user->salt_len)
DBUG_RETURN(CR_ERROR);
- DBUG_RETURN(check_scramble(pkt, thd->scramble, mpvio->acl_user->salt) ?
- CR_ERROR : CR_OK);
+ if (check_scramble(pkt, thd->scramble, mpvio->acl_user->salt))
+ DBUG_RETURN(CR_ERROR);
+ else
+ DBUG_RETURN(CR_OK);
}
- inc_host_errors(mpvio->thd->main_security_ctx.ip);
+ inc_host_errors(mpvio->thd->security_ctx->ip);
my_error(ER_HANDSHAKE_ERROR, MYF(0));
DBUG_RETURN(CR_ERROR);
}
@@ -9334,7 +9323,7 @@ static int old_password_authenticate(MYSQL_PLUGIN_VIO *vio,
CR_ERROR : CR_OK;
}
- inc_host_errors(mpvio->thd->main_security_ctx.ip);
+ inc_host_errors(mpvio->thd->security_ctx->ip);
my_error(ER_HANDSHAKE_ERROR, MYF(0));
return CR_ERROR;
}
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index 3e83aceb03b..a2aeeb86072 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -409,7 +409,7 @@ void field_real::add()
if ((decs = decimals()) == NOT_FIXED_DEC)
{
- length= my_sprintf(buff, (buff, "%g", num));
+ length= sprintf(buff, "%g", num);
if (rint(num) != num)
max_notzero_dec_len = 1;
}
@@ -420,7 +420,7 @@ void field_real::add()
snprintf(buff, sizeof(buff)-1, "%-.*f", (int) decs, num);
length = (uint) strlen(buff);
#else
- length= my_sprintf(buff, (buff, "%-.*f", (int) decs, num));
+ length= sprintf(buff, "%-.*f", (int) decs, num);
#endif
// We never need to check further than this
@@ -1002,9 +1002,9 @@ void field_decimal::get_opt_type(String *answer,
my_decimal_set_zero(&zero);
my_bool is_unsigned= (my_decimal_cmp(&zero, &min_arg) >= 0);
- length= my_sprintf(buff, (buff, "DECIMAL(%d, %d)",
- (int) (max_length - (item->decimals ? 1 : 0)),
- item->decimals));
+ length= sprintf(buff, "DECIMAL(%d, %d)",
+ (int) (max_length - (item->decimals ? 1 : 0)),
+ item->decimals);
if (is_unsigned)
length= (uint) (strmov(buff+length, " UNSIGNED")- buff);
answer->append(buff, length);
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 84adfddc4ac..395ab889a14 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -274,52 +274,6 @@ bool Foreign_key::validate(List<Create_field> &table_fields)
****************************************************************************/
/**
- Get reference to scheduler data object
-
- @param thd THD object
-
- @retval Scheduler data object on THD
-*/
-void *thd_get_scheduler_data(THD *thd)
-{
- return thd->scheduler.data;
-}
-
-/**
- Set reference to Scheduler data object for THD object
-
- @param thd THD object
- @param psi Scheduler data object to set on THD
-*/
-void thd_set_scheduler_data(THD *thd, void *data)
-{
- thd->scheduler.data= data;
-}
-
-/**
- Get reference to Performance Schema object for THD object
-
- @param thd THD object
-
- @retval Performance schema object for thread on THD
-*/
-PSI_thread *thd_get_psi(THD *thd)
-{
- return thd->scheduler.m_psi;
-}
-
-/**
- Set reference to Performance Schema object for THD object
-
- @param thd THD object
- @param psi Performance schema object for thread
-*/
-void thd_set_psi(THD *thd, PSI_thread *psi)
-{
- thd->scheduler.m_psi= psi;
-}
-
-/**
Set the state on connection to killed
@param thd THD object
@@ -405,13 +359,6 @@ THD *thd_get_current_thd()
*/
void thd_new_connection_setup(THD *thd, char *stack_start)
{
-#ifdef HAVE_PSI_INTERFACE
- if (PSI_server)
- thd_set_psi(thd,
- PSI_server->new_thread(key_thread_one_connection,
- thd,
- thd_get_thread_id((MYSQL_THD)thd)));
-#endif
thd->set_time();
thd->prior_thr_create_utime= thd->thr_create_utime= thd->start_utime=
my_micro_time();
@@ -837,7 +784,7 @@ THD::THD()
init_sql_alloc(&main_mem_root, ALLOC_ROOT_MIN_BLOCK_SIZE, 0);
stmt_arena= this;
thread_stack= 0;
- scheduler= &thread_scheduler; // Will be fixed later
+ scheduler= thread_scheduler; // Will be fixed later
extra_port= 0;
catalog= (char*)"std"; // the only catalog we have for now
main_security_ctx.init();
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 9280fbd0640..8556472394d 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -446,6 +446,7 @@ typedef struct system_variables
ulong max_tmp_tables;
ulong max_insert_delayed_threads;
ulong min_examined_row_limit;
+ ulong multi_range_count;
ulong net_buffer_length;
ulong net_interactive_timeout;
ulong net_read_timeout;
@@ -2103,7 +2104,6 @@ public:
char scramble[SCRAMBLE_LENGTH+1];
bool slave_thread, one_shot_set;
- bool no_errors, password;
bool extra_port; /* If extra connection */
bool no_errors;
diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
index c0646e6cec7..3e7c7344a10 100644
--- a/sql/sql_connect.cc
+++ b/sql/sql_connect.cc
@@ -1177,7 +1177,7 @@ void do_handle_one_connection(THD *thd_arg)
thd->thr_create_utime= my_micro_time();
- if (MYSQL_CALLBACK_ELSE(&thread_scheduler, init_new_connection_thread, (), 0))
+ if (MYSQL_CALLBACK_ELSE(thread_scheduler, init_new_connection_thread, (), 0))
{
close_connection(thd, ER_OUT_OF_RESOURCES);
statistic_increment(aborted_connects,&LOCK_status);
diff --git a/sql/sql_connect.h b/sql/sql_connect.h
index 2f3096b496a..6faf595bd17 100644
--- a/sql/sql_connect.h
+++ b/sql/sql_connect.h
@@ -18,6 +18,8 @@
#include "my_sys.h" /* pthread_handler_t */
#include "mysql_com.h" /* enum_server_command */
+#include "structs.h"
+#include <hash.h>
class THD;
typedef struct st_lex_user LEX_USER;
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index 8dd611e4ccf..3a7cc38b097 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -230,8 +230,14 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
order= simple_remove_const(order, conds);
bool need_sort;
- usable_index= get_index_for_order(order, table, select, limit,
- &need_sort, &reverse);
+ if (select && select->quick && select->quick->unique_key_range())
+ { // Single row select (always "ordered")
+ need_sort= FALSE;
+ usable_index= MAX_KEY;
+ }
+ else
+ usable_index= get_index_for_order(order, table, select, limit,
+ &need_sort, &reverse);
if (need_sort)
{
DBUG_ASSERT(usable_index == MAX_KEY);
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index d12b314001a..400cc2683cd 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -977,7 +977,9 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
MYSQL_AUDIT_NOTIFY_CONNECTION_CHANGE_USER(thd);
if (rc)
{
- my_free(thd->security_ctx->user);
+ /* authentication can fail before or after allocating new username */
+ if (thd->security_ctx->user != save_security_ctx.user)
+ my_free(thd->security_ctx->user);
*thd->security_ctx= save_security_ctx;
thd->user_connect= save_user_connect;
thd->reset_db(save_db, save_db_length);
diff --git a/sql/sql_partition.h b/sql/sql_partition.h
index 9a9a0bd56fa..c19eb5802b3 100644
--- a/sql/sql_partition.h
+++ b/sql/sql_partition.h
@@ -96,7 +96,6 @@ bool check_partition_info(partition_info *part_info,handlerton **eng_type,
TABLE *table, handler *file, HA_CREATE_INFO *info);
void set_linear_hash_mask(partition_info *part_info, uint num_parts);
bool fix_partition_func(THD *thd, TABLE *table, bool create_table_ind);
-bool partition_key_modified(TABLE *table, const MY_BITMAP *fields);
void get_partition_set(const TABLE *table, uchar *buf, const uint index,
const key_range *key_spec,
part_id_range *part_spec);
@@ -269,6 +268,9 @@ char *generate_partition_syntax(partition_info *part_info,
bool show_partition_options,
HA_CREATE_INFO *create_info,
Alter_info *alter_info);
+bool partition_key_modified(TABLE *table, const MY_BITMAP *fields);
+#else
+#define partition_key_modified(X,Y) 0
#endif
void create_partition_name(char *out, const char *in1,
diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc
index d36654c4c18..60137d51a5e 100644
--- a/sql/sql_plugin.cc
+++ b/sql/sql_plugin.cc
@@ -513,7 +513,7 @@ static my_bool read_mysql_plugin_info(struct st_plugin_dl *plugin_dl,
{
free_plugin_mem(plugin_dl);
report_error(report, ER_OUTOFMEMORY,
- static_cast<int>(plugin_dl.dl.length));
+ static_cast<int>(plugin_dl->dl.length));
DBUG_RETURN(TRUE);
}
/*
@@ -639,7 +639,7 @@ static my_bool read_maria_plugin_info(struct st_plugin_dl *plugin_dl,
{
free_plugin_mem(plugin_dl);
report_error(report, ER_OUTOFMEMORY,
- static_cast<int>(plugin_dl.dl.length));
+ static_cast<int>(plugin_dl->dl.length));
DBUG_RETURN(TRUE);
}
/*
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 34c61dc2c2b..f4ca5826c65 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1319,11 +1319,11 @@ JOIN::optimize()
*/
no_jbuf_after= 1 ? tables : make_join_orderinfo(this);
+ // Don't use join buffering when we use MATCH
select_opts_for_readinfo=
(select_options & (SELECT_DESCRIBE | SELECT_NO_JOIN_CACHE)) |
(select_lex->ftfunc_list->elements ? SELECT_NO_JOIN_CACHE : 0);
- // No cache for MATCH == 'Don't use join buffering when we use MATCH'.
if (make_join_readinfo(this, select_opts_for_readinfo, no_jbuf_after))
DBUG_RETURN(1);
@@ -15639,18 +15639,16 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
bool no_changes, const key_map *map)
{
int ref_key;
- uint ref_key_parts;
+ uint UNINIT_VAR(ref_key_parts);
int order_direction= 0;
uint used_key_parts;
TABLE *table=tab->table;
SQL_SELECT *select=tab->select;
key_map usable_keys;
- QUICK_SELECT_I *save_quick= 0;
+ QUICK_SELECT_I *save_quick= select ? select->quick : 0;
COND *orig_select_cond= 0;
int best_key= -1;
-
DBUG_ENTER("test_if_skip_sort_order");
- LINT_INIT(ref_key_parts);
/*
Keys disabled by ALTER TABLE ... DISABLE KEYS should have already
@@ -15683,7 +15681,6 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
else if (select && select->quick) // Range found by opt_range
{
int quick_type= select->quick->get_type();
- save_quick= select->quick;
/*
assume results are not ordered when index merge is used
TODO: sergeyp: Results of all index merge selects actually are ordered
@@ -15814,7 +15811,7 @@ test_if_skip_sort_order(JOIN_TAB *tab,ORDER *order,ha_rows select_limit,
join->select_options & OPTION_FOUND_ROWS ?
HA_POS_ERROR :
join->unit->select_limit_cnt,
- TRUE, FALSE) > 0;
+ TRUE, FALSE);
}
order_direction= best_key_direction;
/*
@@ -19877,16 +19874,6 @@ test_if_cheaper_ordering(const JOIN_TAB *tab, ORDER *order, TABLE *table,
uint get_index_for_order(ORDER *order, TABLE *table, SQL_SELECT *select,
ha_rows limit, bool *need_sort, bool *reverse)
{
- if (select && select->quick && select->quick->unique_key_range())
- { // Single row select (always "ordered"): Ok to use with key field UPDATE
- *need_sort= FALSE;
- /*
- Returning of MAX_KEY here prevents updating of used_key_is_modified
- in mysql_update(). Use quick select "as is".
- */
- return MAX_KEY;
- }
-
if (!order)
{
*need_sort= FALSE;
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 2d06f383612..39e3652a1af 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -5975,7 +5975,7 @@ static void store_schema_partitions_record(THD *thd, TABLE *schema_table,
strlen(part_elem->tablespace_name), cs);
else
{
- char *ts= showing_table->s->tablespace;
+ char *ts= showing_table->file->get_tablespace_name(thd,0,0);
if(ts)
table->field[24]->store(ts, strlen(ts), cs);
else
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 7d59598d606..73e9734280f 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -6548,7 +6548,7 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
if (alter_info->keys_onoff != LEAVE_AS_IS ||
table->file->indexes_are_disabled())
need_lock_for_indexes= true;
- if (!table->s->tmp_table &&
+ if (!table->s->tmp_table && need_lock_for_indexes &&
wait_while_table_is_used(thd, table, extra_func))
goto err_new_table_cleanup;
thd_proc_info(thd, "manage keys");
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index bb4540b48f3..0f470062981 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -1,4 +1,5 @@
/* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ Copyright (c) 2011 Monty Program 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
@@ -437,23 +438,37 @@ int mysql_update(THD *thd,
table->update_const_key_parts(conds);
order= simple_remove_const(order, conds);
- used_index= get_index_for_order(order, table, select, limit,
- &need_sort, &reverse);
- if (need_sort)
- { // Assign table scan index to check below for modified key fields:
- used_index= table->file->key_used_on_scan;
+ if (select && select->quick && select->quick->unique_key_range())
+ { // Single row select (always "ordered"): Ok to use with key field UPDATE
+ need_sort= FALSE;
+ used_index= MAX_KEY;
+ used_key_is_modified= FALSE;
}
- if (used_index != MAX_KEY)
- { // Check if we are modifying a key that we are used to search with:
- used_key_is_modified= is_key_used(table, used_index, table->write_set);
+ else
+ {
+ used_index= get_index_for_order(order, table, select, limit,
+ &need_sort, &reverse);
+ if (select && select->quick)
+ {
+ DBUG_ASSERT(need_sort || used_index == select->quick->index);
+ used_key_is_modified= (!select->quick->unique_key_range() &&
+ select->quick->is_keys_used(table->write_set));
+ }
+ else
+ {
+ if (need_sort)
+ { // Assign table scan index to check below for modified key fields:
+ used_index= table->file->key_used_on_scan;
+ }
+ if (used_index != MAX_KEY)
+ { // Check if we are modifying a key that we are used to search with:
+ used_key_is_modified= is_key_used(table, used_index, table->write_set);
+ }
+ }
}
-#ifdef WITH_PARTITION_STORAGE_ENGINE
if (used_key_is_modified || order ||
partition_key_modified(table, table->write_set))
-#else
- if (used_key_is_modified || order)
-#endif
{
/*
We can't update table directly; We must first search after all
@@ -2098,7 +2113,7 @@ int multi_update::do_updates()
{
if ((local_error=
tbl->file->ha_rnd_pos(tbl->record[0],
- (uchar*) tmp_table->field[field_num]->ptr)))
+ (uchar *) tmp_table->field[field_num]->ptr)))
{
err_table= tbl;
goto err;
diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc
index fceaad4eca9..ba86a06847a 100644
--- a/sql/sys_vars.cc
+++ b/sql/sys_vars.cc
@@ -1197,7 +1197,7 @@ static Sys_var_harows Sys_sql_max_join_size(
SESSION_VAR(max_join_size), NO_CMD_LINE,
VALID_RANGE(1, HA_POS_ERROR), DEFAULT(HA_POS_ERROR), BLOCK_SIZE(1),
NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
- ON_UPDATE(fix_max_join_size), DEPRECATED(70000, 0));
+ ON_UPDATE(fix_max_join_size), DEPRECATED(70000, "'@@max_join_size'"));
static Sys_var_ulong Sys_max_long_data_size(
"max_long_data_size",
@@ -1636,6 +1636,13 @@ static Sys_var_ulong Sys_range_alloc_block_size(
VALID_RANGE(RANGE_ALLOC_BLOCK_SIZE, ULONG_MAX),
DEFAULT(RANGE_ALLOC_BLOCK_SIZE), BLOCK_SIZE(1024));
+static Sys_var_ulong Sys_multi_range_count(
+ "multi_range_count", "Ignored. Use mrr_buffer_size instead",
+ SESSION_VAR(multi_range_count), CMD_LINE(REQUIRED_ARG),
+ VALID_RANGE(1, ULONG_MAX), DEFAULT(256), BLOCK_SIZE(1),
+ NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(0),
+ DEPRECATED(50700, "'@@mrr_buffer_size'"));
+
static bool fix_thd_mem_root(sys_var *self, THD *thd, enum_var_type type)
{
if (type != OPT_GLOBAL)
diff --git a/sql/table.cc b/sql/table.cc
index f71df6b9665..8d27d1699f5 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -1141,11 +1141,11 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
share->rec_buff_length= rec_buff_length;
if (!(record= (uchar *) alloc_root(&share->mem_root,
rec_buff_length)))
- goto free_and_err; /* purecov: inspected */
+ goto err; /* purecov: inspected */
share->default_values= record;
if (mysql_file_pread(file, record, (size_t) share->reclength,
record_offset, MYF(MY_NABP)))
- goto free_and_err; /* purecov: inspected */
+ goto err; /* purecov: inspected */
mysql_file_seek(file, pos+288, MY_SEEK_SET, MYF(0));
#ifdef HAVE_CRYPTED_FRM
@@ -1153,7 +1153,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
{
crypted->decode((char*) forminfo+256,288-256);
if (sint2korr(forminfo+284) != 0) // Should be 0
- goto free_and_err; // Wrong password
+ goto err; // Wrong password
}
#endif
@@ -1186,14 +1186,14 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
keys+3)*sizeof(char *)+
(n_length+int_length+com_length+
vcol_screen_length)))))
- goto free_and_err; /* purecov: inspected */
+ goto err; /* purecov: inspected */
share->field= field_ptr;
read_length=(uint) (share->fields * field_pack_length +
pos+ (uint) (n_length+int_length+com_length+
vcol_screen_length));
if (read_string(file,(uchar**) &disk_buff,read_length))
- goto free_and_err; /* purecov: inspected */
+ goto err; /* purecov: inspected */
#ifdef HAVE_CRYPTED_FRM
if (crypted)
{
@@ -1220,7 +1220,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
fix_type_pointers(&interval_array, &share->fieldnames, 1, &names);
if (share->fieldnames.count != share->fields)
- goto free_and_err;
+ goto err;
fix_type_pointers(&interval_array, share->intervals, interval_count,
&names);
@@ -1234,7 +1234,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
uint count= (uint) (interval->count + 1) * sizeof(uint);
if (!(interval->type_lengths= (uint *) alloc_root(&share->mem_root,
count)))
- goto free_and_err;
+ goto err;
for (count= 0; count < interval->count; count++)
{
char *val= (char*) interval->type_names[count];
@@ -1250,7 +1250,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
/* Allocate handler */
if (!(handler_file= get_new_handler(share, thd->mem_root,
share->db_type())))
- goto free_and_err;
+ goto err;
record= share->default_values-1; /* Fieldstart = 1 */
null_bits_are_used= share->null_fields != 0;
@@ -1313,7 +1313,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
charset= &my_charset_bin;
#else
error= 4; // unsupported field type
- goto free_and_err;
+ goto err;
#endif
}
else
@@ -1325,7 +1325,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
{
error= 5; // Unknown or unavailable charset
errarg= (int) csid;
- goto free_and_err;
+ goto err;
}
}
@@ -1365,7 +1365,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if ((uint)vcol_screen_pos[0] != 1)
{
error= 4;
- goto free_and_err;
+ goto err;
}
field_type= (enum_field_types) (uchar) vcol_screen_pos[1];
fld_stored_in_db= (bool) (uint) vcol_screen_pos[2];
@@ -1374,7 +1374,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
(char *)memdup_root(&share->mem_root,
vcol_screen_pos+(uint)FRM_VCOL_HEADER_SIZE,
vcol_expr_length)))
- goto free_and_err;
+ goto err;
vcol_info->expr_str.length= vcol_expr_length;
vcol_screen_pos+= vcol_info_length;
share->vfields++;
@@ -1464,7 +1464,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (!reg_field) // Not supported field type
{
error= 4;
- goto free_and_err; /* purecov: inspected */
+ goto err; /* purecov: inspected */
}
reg_field->field_index= i;
@@ -1504,7 +1504,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
sent (OOM).
*/
error= 8;
- goto free_and_err;
+ goto err;
}
}
if (!reg_field->stored_in_db)
@@ -1581,7 +1581,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
if (!key_part->fieldnr)
{
error= 4; // Wrong file
- goto free_and_err;
+ goto err;
}
field= key_part->field= share->field[key_part->fieldnr-1];
key_part->type= field->key_type();
@@ -1743,11 +1743,10 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head,
{
DBUG_ASSERT(options_len);
if (engine_table_options_frm_read(options, options_len, share))
- goto free_and_err;
+ goto err;
}
if (parse_engine_table_options(thd, handler_file->partition_ht(), share))
- goto free_and_err;
- my_free(buff);
+ goto err;
if (share->found_next_number_field)
{
@@ -2059,7 +2058,7 @@ bool unpack_vcol_info_from_frm(THD *thd,
vcol_arena= table->expr_arena;
if (!vcol_arena)
{
- Query_arena expr_arena(&table->mem_root, Query_arena::INITIALIZED);
+ Query_arena expr_arena(&table->mem_root, Query_arena::STMT_INITIALIZED);
if (!(vcol_arena= (Query_arena *) alloc_root(&table->mem_root,
sizeof(Query_arena))))
goto err;
@@ -2145,12 +2144,12 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias,
bool error_reported= FALSE;
uchar *record, *bitmaps;
Field **field_ptr, **vfield_ptr;
- bool save_view_prepare_mode= thd->lex->view_prepare_mode;
+ uint8 save_view_prepare_mode= thd->lex->context_analysis_only;
DBUG_ENTER("open_table_from_share");
DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx", share->db.str,
share->table_name.str, (long) outparam));
- thd->lex->view_prepare_mode= FALSE; // not a view
+ thd->lex->context_analysis_only&= ~CONTEXT_ANALYSIS_ONLY_VIEW; // not a view
error= 1;
bzero((char*) outparam, sizeof(*outparam));
@@ -2480,7 +2479,7 @@ partititon_err:
HA_HAS_OWN_BINLOGGING);
thd->status_var.opened_tables++;
- thd->lex->view_prepare_mode= save_view_prepare_mode;
+ thd->lex->context_analysis_only= save_view_prepare_mode;
DBUG_RETURN (0);
err:
@@ -2493,7 +2492,7 @@ partititon_err:
#endif
outparam->file= 0; // For easier error checking
outparam->db_stat=0;
- thd->lex->view_prepare_mode= save_view_prepare_mode;
+ thd->lex->context_analysis_only= save_view_prepare_mode;
free_root(&outparam->mem_root, MYF(0)); // Safe to call on bzero'd root
my_free((void *) outparam->alias);
DBUG_RETURN (error);