Commit 70a4cf9d authored by unknown's avatar unknown

Merge mysql.com:/home/jonas/src/mysql-5.0

into mysql.com:/home/jonas/src/mysql-5.0-ndb

parents 49206d2d 9bb865be
......@@ -332,6 +332,9 @@ inline double ulonglong2double(ulonglong value)
#define SHAREDIR "share"
#define DEFAULT_CHARSET_HOME "C:/mysql/"
#endif
#ifndef DEFAULT_HOME_ENV
#define DEFAULT_HOME_ENV MYSQL_HOME
#endif
/* File name handling */
......
......@@ -139,6 +139,14 @@ ib_time_t
ut_time(void);
/*=========*/
/**************************************************************
Returns system time. */
void
ut_usectime(
/*========*/
ulint* sec, /* out: seconds since the Epoch */
ulint* ms); /* out: microseconds since the Epoch+*sec */
/**************************************************************
Returns the difference of two times in seconds. */
double
......
......@@ -443,7 +443,8 @@ mlog_open_and_write_index(
type = dict_col_get_type(dict_field_get_col(field));
len = field->fixed_len;
ut_ad(len < 0x7fff);
if (len == 0 && dtype_get_len(type) > 255) {
if (len == 0 && (dtype_get_len(type) > 255
|| dtype_get_mtype(type) == DATA_BLOB)) {
/* variable-length field
with maximum length > 255 */
len = 0x7fff;
......
......@@ -346,10 +346,10 @@ static ulint srv_n_rows_updated_old = 0;
static ulint srv_n_rows_deleted_old = 0;
static ulint srv_n_rows_read_old = 0;
ulint srv_n_lock_wait_count= 0;
ulint srv_n_lock_wait_current_count= 0;
ib_longlong srv_n_lock_wait_time= 0;
ulint srv_n_lock_max_wait_time= 0;
ulint srv_n_lock_wait_count = 0;
ulint srv_n_lock_wait_current_count = 0;
ib_longlong srv_n_lock_wait_time = 0;
ulint srv_n_lock_max_wait_time = 0;
/*
......@@ -1384,10 +1384,11 @@ srv_suspend_mysql_thread(
trx_t* trx;
ibool had_dict_lock = FALSE;
ibool was_declared_inside_innodb = FALSE;
ib_longlong start_time, finish_time;
ulint diff_time;
ulint sec;
ulint ms;
ib_longlong start_time = 0;
ib_longlong finish_time;
ulint diff_time;
ulint sec;
ulint ms;
#ifdef UNIV_SYNC_DEBUG
ut_ad(!mutex_own(&kernel_mutex));
......@@ -1430,15 +1431,14 @@ srv_suspend_mysql_thread(
os_event_reset(event);
slot->suspend_time = ut_time();
if (thr->lock_state == QUE_THR_LOCK_ROW)
{
srv_n_lock_wait_count++;
srv_n_lock_wait_current_count++;
ut_usectime(&sec, &ms);
start_time= (ib_longlong)sec * 1000000 + ms;
if (thr->lock_state == QUE_THR_LOCK_ROW) {
srv_n_lock_wait_count++;
srv_n_lock_wait_current_count++;
}
ut_usectime(&sec, &ms);
start_time = (ib_longlong)sec * 1000000 + ms;
}
/* Wake the lock timeout monitor thread, if it is suspended */
os_event_set(srv_lock_timeout_thread_event);
......@@ -1490,20 +1490,18 @@ srv_suspend_mysql_thread(
wait_time = ut_difftime(ut_time(), slot->suspend_time);
if (thr->lock_state == QUE_THR_LOCK_ROW)
{
ut_usectime(&sec, &ms);
finish_time= (ib_longlong)sec * 1000000 + ms;
diff_time= finish_time-start_time;
if (thr->lock_state == QUE_THR_LOCK_ROW) {
ut_usectime(&sec, &ms);
finish_time = (ib_longlong)sec * 1000000 + ms;
diff_time = finish_time - start_time;
srv_n_lock_wait_current_count--;
srv_n_lock_wait_time= srv_n_lock_wait_time + diff_time;
if (diff_time > srv_n_lock_max_wait_time)
{
srv_n_lock_max_wait_time= diff_time;
}
}
srv_n_lock_wait_current_count--;
srv_n_lock_wait_time = srv_n_lock_wait_time + diff_time;
if (diff_time > srv_n_lock_max_wait_time) {
srv_n_lock_max_wait_time = diff_time;
}
}
if (trx->was_chosen_as_deadlock_victim) {
......
......@@ -368,7 +368,7 @@ mutex_spin_wait(
{
ulint index; /* index of the reserved wait cell */
ulint i; /* spin round count */
ib_longlong lstart_time, lfinish_time; /* for timing os_wait */
ib_longlong lstart_time = 0, lfinish_time; /* for timing os_wait */
ulint ltime_diff;
ulint sec;
ulint ms;
......
......@@ -74,18 +74,18 @@ ut_time(void)
}
/**************************************************************
Returns system time. We do not specify the format of the time returned:
the only way to manipulate it is to use the function ut_difftime. */
Returns system time. */
void
ut_usectime(ulint* sec, ulint* ms)
/*=========*/
ut_usectime(
/*========*/
ulint* sec, /* out: seconds since the Epoch */
ulint* ms) /* out: microseconds since the Epoch+*sec */
{
struct timeval tv;
gettimeofday(&tv,NULL);
*sec = (ulint) tv.tv_sec;
*ms = (ulint) tv.tv_usec;
return;
struct timeval tv;
gettimeofday(&tv,NULL);
*sec = (ulint) tv.tv_sec;
*ms = (ulint) tv.tv_usec;
}
/**************************************************************
......
......@@ -81,6 +81,7 @@ CLEANFILES = $(target_libadd) $(SHLIBOBJS) \
$(target)
DEFS = -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
-DDEFAULT_HOME_ENV=MYSQL_HOME \
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
# The automatic dependencies miss this
......
......@@ -47,6 +47,8 @@ Warnings:
Note 1305 PROCEDURE foo does not exist
show create procedure foo|
ERROR 42000: PROCEDURE foo does not exist
show create function foo|
ERROR 42000: FUNCTION foo does not exist
create procedure foo()
foo: loop
leave bar;
......
......@@ -363,107 +363,6 @@ v4 CREATE ALGORITHM=TEMPTABLE VIEW `mysqltest`.`v4` AS select (`mysqltest`.`t2`.
revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1';
drop database mysqltest;
set GLOBAL query_cache_size=1355776;
flush status;
create table t1 (a int, b int);
create view v1 (c,d) as select sql_no_cache a,b from t1;
create view v2 (c,d) as select a+rand(),b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
drop view v1,v2;
set query_cache_type=demand;
flush status;
create view v1 (c,d) as select sql_cache a,b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
drop view v1;
set query_cache_type=default;
drop table t1;
set GLOBAL query_cache_size=default;
create table t1 (a int);
insert into t1 values (1), (2), (3), (1), (2), (3);
create view v1 as select distinct a from t1;
......
set GLOBAL query_cache_size=1355776;
flush status;
create table t1 (a int, b int);
create view v1 (c,d) as select sql_no_cache a,b from t1;
create view v2 (c,d) as select a+rand(),b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
select * from v2;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
drop view v1,v2;
set query_cache_type=demand;
flush status;
create view v1 (c,d) as select sql_cache a,b from t1;
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 0
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 0
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 0
select * from v1;
c d
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
select * from t1;
a b
show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 1
show status like "Qcache_inserts";
Variable_name Value
Qcache_inserts 1
show status like "Qcache_hits";
Variable_name Value
Qcache_hits 1
drop view v1;
set query_cache_type=default;
drop table t1;
set GLOBAL query_cache_size=default;
......@@ -81,6 +81,8 @@ call foo()|
drop procedure if exists foo|
--error 1305
show create procedure foo|
--error 1305
show create function foo|
# LEAVE/ITERATE/GOTO with no match
--error 1308
......
......@@ -328,63 +328,6 @@ revoke all privileges on mysqltest.* from mysqltest_1@localhost;
delete from mysql.user where user='mysqltest_1';
drop database mysqltest;
#
# QUERY CACHE options for VIEWs
#
set GLOBAL query_cache_size=1355776;
flush status;
create table t1 (a int, b int);
# queries with following views should not be in query cache
create view v1 (c,d) as select sql_no_cache a,b from t1;
create view v2 (c,d) as select a+rand(),b from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
select * from v2;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
select * from v2;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
drop view v1,v2;
# SQL_CACHE option
set query_cache_type=demand;
flush status;
# query with view will be cached, but direct acess to table will not
create view v1 (c,d) as select sql_cache a,b from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
drop view v1;
set query_cache_type=default;
drop table t1;
set GLOBAL query_cache_size=default;
#
# DISTINCT option for VIEW
#
......
-- source include/have_query_cache.inc
#
# QUERY CACHE options for VIEWs
#
set GLOBAL query_cache_size=1355776;
flush status;
create table t1 (a int, b int);
# queries with following views should not be in query cache
create view v1 (c,d) as select sql_no_cache a,b from t1;
create view v2 (c,d) as select a+rand(),b from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
select * from v2;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
select * from v2;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
drop view v1,v2;
# SQL_CACHE option
set query_cache_type=demand;
flush status;
# query with view will be cached, but direct acess to table will not
create view v1 (c,d) as select sql_cache a,b from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from v1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
select * from t1;
show status like "Qcache_queries_in_cache";
show status like "Qcache_inserts";
show status like "Qcache_hits";
drop view v1;
set query_cache_type=default;
drop table t1;
set GLOBAL query_cache_size=default;
......@@ -66,6 +66,7 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
-DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
-DDEFAULT_HOME_ENV=MYSQL_HOME \
@DEFS@
libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
......
......@@ -45,23 +45,8 @@ char *defaults_extra_file=0;
/* Which directories are searched for options (and in which order) */
const char *default_directories[]= {
#ifdef __WIN__
"C:/",
#elif defined(__NETWARE__)
"sys:/etc/",
#else
"/etc/",
#endif
#ifdef DATADIR
DATADIR,
#endif
"", /* Place for defaults_extra_dir */
#if !defined(__WIN__) && !defined(__NETWARE__)
"~/",
#endif
NullS,
};
#define MAX_DEFAULT_DIRS 4
const char *default_directories[MAX_DEFAULT_DIRS + 1];
#ifdef __WIN__
static const char *f_extensions[]= { ".ini", ".cnf", 0 };
......@@ -89,6 +74,7 @@ static int search_default_file_with_ext(Process_option_func func,
void *func_ctx,
const char *dir, const char *ext,
const char *config_file);
static void init_default_directories();
static char *remove_end_comment(char *ptr);
......@@ -319,6 +305,7 @@ int load_defaults(const char *conf_file, const char **groups,
struct handle_option_ctx ctx;
DBUG_ENTER("load_defaults");
init_default_directories();
init_alloc_root(&alloc,512,0);
if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults"))
{
......@@ -652,6 +639,7 @@ void print_defaults(const char *conf_file, const char **groups)
char name[FN_REFLEN], **ext;
const char **dirs;
init_default_directories();
puts("\nDefault options are read from the following files in the given order:");
if (dirname_length(conf_file))
......@@ -714,3 +702,23 @@ void print_defaults(const char *conf_file, const char **groups)
}
#include <help_end.h>
static void init_default_directories()
{
const char *env, **ptr= default_directories;
#ifdef __WIN__
*ptr++= "C:/";
#elif defined(__NETWARE__)
*ptr++= "sys:/etc/";
#else
*ptr++= "/etc/";
#endif
if ((env= getenv(STRINGIFY_ARG(DEFAULT_HOME_ENV))))
*ptr++= env;
*ptr++= ""; /* Place for defaults_extra_file */
#if !defined(__WIN__) && !defined(__NETWARE__)
*ptr++= "~/";;
#endif
*ptr= 0; /* end marker */
}
......@@ -4,7 +4,7 @@ use Getopt::Long;
use POSIX qw(strftime);
$|=1;
$VER="2.11";
$VER="2.12";
$opt_config_file = undef();
$opt_example = 0;
......@@ -430,6 +430,16 @@ sub find_groups
{
$data[$i] = $line;
}
if (defined($ENV{MYSQL_HOME}) && -f "$ENV{MYSQL_HOME}/my.cnf" &&
-r "$ENV{MYSQL_HOME}/my.cnf")
{
open(MY_CNF, "<$ENV{MYSQL_HOME}/my.cnf") && (@tmp=<MY_CNF>) &&
close(MY_CNF);
}
for (; ($line = shift @tmp); $i++)
{
$data[$i] = $line;
}
if (-f "$homedir/.my.cnf" && -r "$homedir/.my.cnf")
{
open(MY_CNF, "<$homedir/.my.cnf") && (@tmp=<MY_CNF>) && close(MY_CNF);
......
......@@ -52,11 +52,7 @@ parse_arguments() {
# mysqld_safe-specific options - must be set in my.cnf ([mysqld_safe])!
--ledir=*) ledir=`echo "$arg" | sed -e "s;--ledir=;;"` ;;
# err-log should be removed in 5.0
--err-log=*) err_log=`echo "$arg" | sed -e "s;--err-log=;;"` ;;
--log-error=*) err_log=`echo "$arg" | sed -e "s;--log-error=;;"` ;;
# QQ The --open-files should be removed in 5.0
--open-files=*) open_files=`echo "$arg" | sed -e "s;--open-files=;;"` ;;
--open-files-limit=*) open_files=`echo "$arg" | sed -e "s;--open-files-limit=;;"` ;;
--core-file-size=*) core_file_size=`echo "$arg" | sed -e "s;--core-file-size=;;"` ;;
--timezone=*) TZ=`echo "$arg" | sed -e "s;--timezone=;;"` ; export TZ; ;;
......@@ -94,7 +90,7 @@ then
DATADIR=$MY_BASEDIR_VERSION/data
if test -z "$defaults"
then
defaults="--defaults-extra-file=$MY_BASEDIR_VERSION/data/my.cnf"
defaults="--defaults-extra-file=$DATADIR/my.cnf"
fi
# Check if this is a 'moved install directory'
elif test -f ./var/mysql/db.frm -a -f ./share/mysql/english/errmsg.sys -a \
......@@ -106,8 +102,17 @@ then
else
MY_BASEDIR_VERSION=@prefix@
DATADIR=@localstatedir@
if test -z "$MYSQL_HOME"
then
MYSQL_HOME=$DATADIR # Installation in a not common path
fi
ledir=@libexecdir@
fi
if test -z "$MYSQL_HOME"
then
MYSQL_HOME=$MY_BASEDIR_VERSION
fi
export MYSQL_HOME
user=@MYSQLD_USER@
niceness=0
......
......@@ -376,12 +376,12 @@ static byte* federated_get_key(FEDERATED_SHARE *share,uint *length,
parse_url()
share pointer to FEDERATED share
table pointer to current TABLE class
DESCRIPTION
populates the share with information about the connection
to the remote database that will serve as the data source.
This string must be specified (currently) in the "comment" field,
listed in the CREATE TABLE statement.
listed in the CREATE TABLE statement.
This string MUST be in the format of any of these:
......@@ -401,10 +401,10 @@ static byte* federated_get_key(FEDERATED_SHARE *share,uint *length,
RETURN VALUE
0 success
-1 failure, wrong string format
-1 failure, wrong string format
*/
int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_flag)
static int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_flag)
{
DBUG_ENTER("ha_federated::parse_url");
......@@ -429,7 +429,7 @@ int parse_url(FEDERATED_SHARE *share, TABLE *table, uint table_create_flag)
}
share->username+= 3;
if (share->hostname= strchr(share->username, '@'))
if (share->hostname= strchr(share->username, '@'))
{
share->username[share->hostname - share->username]= '\0';
share->hostname++;
......@@ -1522,7 +1522,7 @@ void ha_federated::position(const byte *record)
{
DBUG_ENTER("ha_federated::position");
//ha_store_ptr Add seek storage
ha_store_ptr(ref, ref_length, current_position);
*(MYSQL_ROW_OFFSET *)ref=current_position;
DBUG_VOID_RETURN;
}
......@@ -1541,7 +1541,7 @@ int ha_federated::rnd_pos(byte * buf, byte *pos)
{
DBUG_ENTER("ha_federated::rnd_pos");
statistic_increment(table->in_use->status_var.ha_read_rnd_count,&LOCK_status);
current_position= ha_get_ptr(pos,ref_length);
current_position= *(MYSQL_ROW_OFFSET *)pos;
result->current_row= 0;
result->data_cursor= current_position;
DBUG_RETURN(rnd_next(buf));
......@@ -1706,10 +1706,10 @@ THR_LOCK_DATA **ha_federated::store_lock(THD *thd,
int ha_federated::create(const char *name, TABLE *table_arg,
HA_CREATE_INFO *create_info)
{
DBUG_ENTER("ha_federated::create");
int retcode;
FEDERATED_SHARE *tmp;
retcode= parse_url(tmp, table_arg, 1);
FEDERATED_SHARE tmp;
DBUG_ENTER("ha_federated::create");
retcode= parse_url(&tmp, table_arg, 1);
if (retcode < 0)
{
DBUG_PRINT("ha_federated::create",
......
......@@ -194,8 +194,8 @@ bool Item_func::agg_arg_charsets(DTCollation &coll,
}
if ((*arg)->type() == FIELD_ITEM)
((Item_field *)(*arg))->no_const_subst= 1;
conv->fix_fields(thd, 0, &conv);
*arg= conv;
conv->fix_fields(thd, 0, arg);
}
if (arena)
thd->restore_backup_item_arena(arena, &backup);
......
......@@ -2262,7 +2262,7 @@ find_field_in_tables(THD *thd, Item_ident *item, TABLE_LIST *tables,
field makes some prepared query ambiguous and so erroneous, but we
accept this trade off.
*/
if (item->cached_table->table)
if (item->cached_table->table && !item->cached_table->view)
{
found= find_field_in_real_table(thd, item->cached_table->table,
name, length,
......@@ -3049,8 +3049,12 @@ insert_fields(THD *thd, TABLE_LIST *tables, const char *db_name,
Item *item= iterator->item(thd);
if (view && !thd->lex->current_select->no_wrap_view_item)
{
item= new Item_ref(it->ref(), tables->view_name.str,
field_name);
/*
as far as we have view, then item point to view_iter, so we
can use it directly for this view specific operation
*/
item= new Item_ref(view_iter.item_ptr(), tables->view_name.str,
field_name);
}
if (!found++)
(void) it->replace(item); // Replace '*'
......@@ -3328,7 +3332,8 @@ int setup_conds(THD *thd, TABLE_LIST *tables, TABLE_LIST *leaves, COND **conds)
thd->restore_backup_item_arena(arena, &backup);
if (embedded->on_expr && !embedded->on_expr->fixed)
{
if (embedded->on_expr->fix_fields(thd, tables, &table->on_expr))
if (embedded->on_expr->fix_fields(thd, tables,
&embedded->on_expr))
goto err_no_arena;
}
}
......
......@@ -52,6 +52,7 @@
#define SP_COM_STRING(LP) \
((LP)->sql_command == SQLCOM_CREATE_SPFUNCTION || \
(LP)->sql_command == SQLCOM_ALTER_FUNCTION || \
(LP)->sql_command == SQLCOM_SHOW_CREATE_FUNC || \
(LP)->sql_command == SQLCOM_DROP_FUNCTION ? \
"FUNCTION" : "PROCEDURE")
......
......@@ -906,6 +906,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
DBUG_RETURN(TRUE);
}
if ((values= its++))
{
uint value_count;
......@@ -927,6 +928,16 @@ static bool mysql_test_insert(Prepared_statement *stmt,
value_count= values->elements;
its.rewind();
res= TRUE;
if (table_list->lock_type == TL_WRITE_DELAYED &&
!(table_list->table->file->table_flags() & HA_CAN_INSERT_DELAYED))
{
my_error(ER_ILLEGAL_HA, MYF(0), (table_list->view ?
table_list->view_name.str :
table_list->real_name));
goto error;
}
while ((values= its++))
{
counter++;
......@@ -940,7 +951,7 @@ static bool mysql_test_insert(Prepared_statement *stmt,
}
}
res= 0;
res= FALSE;
error:
lex->unit.cleanup();
/* insert_values is cleared in open_table */
......
......@@ -5577,6 +5577,7 @@ insert:
LEX *lex= Lex;
lex->sql_command= SQLCOM_INSERT;
lex->duplicates= DUP_ERROR;
mysql_init_select(lex);
/* for subselects */
lex->lock_option= (using_update_log) ? TL_READ_NO_INSERT : TL_READ;
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
......@@ -5596,6 +5597,7 @@ replace:
LEX *lex=Lex;
lex->sql_command = SQLCOM_REPLACE;
lex->duplicates= DUP_REPLACE;
mysql_init_select(lex);
lex->select_lex.resolve_mode= SELECT_LEX::INSERT_MODE;
}
replace_lock_option insert2
......@@ -5796,6 +5798,7 @@ delete:
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_DELETE;
mysql_init_select(lex);
lex->lock_option= lex->thd->update_lock_default;
lex->ignore= 0;
lex->select_lex.init_order();
......@@ -7124,6 +7127,7 @@ set:
{
LEX *lex=Lex;
lex->sql_command= SQLCOM_SET_OPTION;
mysql_init_select(lex);
lex->option_type=OPT_SESSION;
lex->var_list.empty();
lex->one_shot_set= 0;
......@@ -7190,7 +7194,6 @@ option_value:
}
else
lex->var_list.push_back(new set_var_user(new Item_func_set_user_var($2,$4)));
}
| internal_variable_name equal set_expr_or_default
{
......
......@@ -1702,6 +1702,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
if (field_translation)
{
DBUG_PRINT("info", ("there are already translation table"));
/* prevent look up in SELECTs tree */
thd->lex->current_select= &thd->lex->select_lex;
thd->lex->select_lex.no_wrap_view_item= 1;
......@@ -1727,7 +1728,7 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
if (where && !where->fixed && where->fix_fields(thd, ancestor, &where))
goto err;
if (check_option && !check_option->fixed &&
check_option->fix_fields(thd, ancestor, &where))
check_option->fix_fields(thd, ancestor, &check_option))
goto err;
restore_want_privilege();
......@@ -1767,11 +1768,11 @@ bool st_table_list::setup_ancestor(THD *thd, Item **conds,
{
/* save original name of view column */
char *name= item->name;
if (!item->fixed && item->fix_fields(thd, ancestor, &item))
transl[i].item= item;
if (!item->fixed && item->fix_fields(thd, ancestor, &transl[i].item))
goto err;
/* set new item get in fix fields and original column name */
transl[i].name= name;
transl[i++].item= item;
transl[i++].name= name;
}
field_translation= transl;
/* TODO: sort this list? Use hash for big number of fields */
......
......@@ -428,6 +428,7 @@ class Field_iterator_view: public Field_iterator
bool end_of_fields() { return ptr == array_end; }
const char *name();
Item *item(THD *thd) { return ptr->item; }
Item **item_ptr() {return &ptr->item; }
Field *field() { return 0; }
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment