mirror of
https://github.com/MariaDB/server.git
synced 2025-01-25 00:04:33 +01:00
Merge bk-internal:/home/bk/mysql-5.0
into serg.mylan:/usr/home/serg/Abk/mysql-5.0
This commit is contained in:
commit
3e5491e6e9
16 changed files with 289 additions and 94 deletions
|
@ -3871,6 +3871,14 @@ int update_state_info(MI_CHECK *param, MI_INFO *info,uint update)
|
|||
if (!share->state.create_time)
|
||||
share->state.create_time=share->state.check_time;
|
||||
}
|
||||
/*
|
||||
When tables are locked we haven't synched the share state and the
|
||||
real state for a while so we better do it here before synching
|
||||
the share state to disk. Only when table is write locked is it
|
||||
necessary to perform this synch.
|
||||
*/
|
||||
if (info->lock_type == F_WRLCK)
|
||||
share->state.state= *info->state;
|
||||
if (mi_state_info_write(share->kfile,&share->state,1+2))
|
||||
goto err;
|
||||
share->changed=0;
|
||||
|
|
32
mysql-test/r/analyze.result
Normal file
32
mysql-test/r/analyze.result
Normal file
|
@ -0,0 +1,32 @@
|
|||
create table t1 (a bigint);
|
||||
lock tables t1 write;
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
unlock tables;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
lock tables t1 write;
|
||||
delete from t1;
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
unlock tables;
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
drop table t1;
|
|
@ -596,3 +596,9 @@ ERROR 42000: Incorrect database name 'xyz'
|
|||
create table t1(t1.name int);
|
||||
create table t2(test.t2.name int);
|
||||
drop table t1,t2;
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
drop database mysqltest;
|
||||
create table test.t1 like x;
|
||||
ERROR 42000: Incorrect database name 'NULL'
|
||||
drop table if exists test.t1;
|
||||
|
|
|
@ -132,6 +132,22 @@ a b
|
|||
handler t2 read last;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
|
||||
handler t2 close;
|
||||
handler t1 open;
|
||||
handler t1 read a next;
|
||||
a b
|
||||
14 aaa
|
||||
handler t1 read a next;
|
||||
a b
|
||||
15 bbb
|
||||
handler t1 close;
|
||||
handler t1 open;
|
||||
handler t1 read a prev;
|
||||
a b
|
||||
22 iii
|
||||
handler t1 read a prev;
|
||||
a b
|
||||
21 hhh
|
||||
handler t1 close;
|
||||
handler t1 open as t2;
|
||||
handler t2 read first;
|
||||
a b
|
||||
|
|
|
@ -138,6 +138,8 @@ t1 CREATE TABLE `t1` (
|
|||
`min_num` decimal(7,6) default '0.000001'
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1 ;
|
||||
set @@SQL_MODE=NULL;
|
||||
ERROR 42000: Variable 'sql_mode' can't be set to the value of 'NULL'
|
||||
SET @OLD_SQL_MODE=@@SQL_MODE, @@SQL_MODE='';
|
||||
show local variables like 'SQL_MODE';
|
||||
Variable_name Value
|
||||
|
|
39
mysql-test/t/analyze.test
Normal file
39
mysql-test/t/analyze.test
Normal file
|
@ -0,0 +1,39 @@
|
|||
#
|
||||
# Bug #10901 Analyze Table on new table destroys table
|
||||
# This is minimal test case to get error
|
||||
# The problem was that analyze table wrote the shared state to the file and this
|
||||
# didn't include the inserts while locked. A check was needed to ensure that
|
||||
# state information was not updated when executing analyze table for a locked table.
|
||||
# The analyze table had to be within locks and check table had to be after unlocking
|
||||
# since then it brings the wrong state from disk rather than from the currently
|
||||
# correct internal state. The insert is needed since it changes the file state,
|
||||
# number of records.
|
||||
# The fix is to synchronise the state of the shared state and the current state before
|
||||
# calling mi_state_info_write
|
||||
#
|
||||
create table t1 (a bigint);
|
||||
lock tables t1 write;
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
unlock tables;
|
||||
check table t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
lock tables t1 write;
|
||||
delete from t1;
|
||||
analyze table t1;
|
||||
unlock tables;
|
||||
check table t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
create table t1 (a bigint);
|
||||
insert into t1 values(0);
|
||||
analyze table t1;
|
||||
check table t1;
|
||||
|
||||
drop table t1;
|
||||
|
|
@ -503,3 +503,14 @@ create table t1(t1.name int);
|
|||
create table t2(test.t2.name int);
|
||||
drop table t1,t2;
|
||||
|
||||
#
|
||||
# Bug#11028: Crash on create table like
|
||||
#
|
||||
create database mysqltest;
|
||||
use mysqltest;
|
||||
drop database mysqltest;
|
||||
--error 1102
|
||||
create table test.t1 like x;
|
||||
--disable_warnings
|
||||
drop table if exists test.t1;
|
||||
--enable_warnings
|
||||
|
|
|
@ -69,6 +69,16 @@ handler t2 read next;
|
|||
handler t2 read last;
|
||||
handler t2 close;
|
||||
|
||||
handler t1 open;
|
||||
handler t1 read a next; # this used to crash as a bug#5373
|
||||
handler t1 read a next;
|
||||
handler t1 close;
|
||||
|
||||
handler t1 open;
|
||||
handler t1 read a prev; # this used to crash as a bug#5373
|
||||
handler t1 read a prev;
|
||||
handler t1 close;
|
||||
|
||||
handler t1 open as t2;
|
||||
handler t2 read first;
|
||||
alter table t1 engine=innodb;
|
||||
|
|
|
@ -80,6 +80,11 @@ create table t1 ( min_num dec(6,6) default .000001);
|
|||
show create table t1;
|
||||
drop table t1 ;
|
||||
|
||||
#
|
||||
# Bug #10732: Set SQL_MODE to NULL gives garbled error message
|
||||
#
|
||||
--error 1231
|
||||
set @@SQL_MODE=NULL;
|
||||
|
||||
#
|
||||
# test for
|
||||
|
|
|
@ -37,22 +37,20 @@
|
|||
#define NEWLINE_LEN 1
|
||||
#endif
|
||||
|
||||
static char *add_option(char *dst, const char *option_value,
|
||||
const char *option, int remove_option);
|
||||
|
||||
int modify_defaults_file(const char *file_location, const char *option,
|
||||
const char *option_value,
|
||||
const char *section_name, int remove_option)
|
||||
{
|
||||
FILE *cnf_file;
|
||||
MY_STAT file_stat;
|
||||
char linebuff[BUFF_SIZE], tmp[BUFF_SIZE], *tmp_ptr, *src_ptr, *dst_ptr,
|
||||
*file_buffer;
|
||||
uint optlen, optval_len, sect_len;
|
||||
my_bool in_section= FALSE;
|
||||
char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
|
||||
uint optlen, optval_len, sect_len, nr_newlines= 0;
|
||||
my_bool in_section= FALSE, opt_applied= 0;
|
||||
DBUG_ENTER("modify_defaults_file");
|
||||
|
||||
optlen= strlen(option);
|
||||
optval_len= strlen(option_value);
|
||||
sect_len= strlen(section_name);
|
||||
|
||||
if (!(cnf_file= my_fopen(file_location, O_RDWR | O_BINARY, MYF(0))))
|
||||
DBUG_RETURN(2);
|
||||
|
||||
|
@ -60,12 +58,15 @@ int modify_defaults_file(const char *file_location, const char *option,
|
|||
if (my_fstat(fileno(cnf_file), &file_stat, MYF(0)))
|
||||
goto err;
|
||||
|
||||
optlen= strlen(option);
|
||||
optval_len= strlen(option_value);
|
||||
|
||||
/*
|
||||
Reserve space to read the contents of the file and some more
|
||||
for the option we want to add.
|
||||
*/
|
||||
if (!(file_buffer= (char*) my_malloc(sizeof(char)*
|
||||
(file_stat.st_size +
|
||||
if (!(file_buffer= (char*) my_malloc(sizeof(char) *
|
||||
(file_stat.st_size +
|
||||
/* option name len */
|
||||
optlen +
|
||||
/* reserve space for newline */
|
||||
|
@ -73,35 +74,44 @@ int modify_defaults_file(const char *file_location, const char *option,
|
|||
/* reserve for '=' char */
|
||||
1 +
|
||||
/* option value len */
|
||||
optval_len), MYF(MY_WME))))
|
||||
optval_len +
|
||||
/* The ending zero plus some safety */
|
||||
FN_REFLEN), MYF(MY_WME))))
|
||||
goto malloc_err;
|
||||
|
||||
for (dst_ptr= file_buffer, tmp_ptr= 0;
|
||||
fgets(linebuff, BUFF_SIZE, cnf_file); )
|
||||
sect_len= strlen(section_name);
|
||||
|
||||
for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); )
|
||||
{
|
||||
/* Skip over whitespaces */
|
||||
for (src_ptr= linebuff; my_isspace(&my_charset_latin1, *src_ptr);
|
||||
src_ptr++)
|
||||
{}
|
||||
|
||||
if (in_section && !strncmp(src_ptr, option, optlen) &&
|
||||
if (!*src_ptr) /* Empty line */
|
||||
{
|
||||
nr_newlines++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!opt_applied && in_section && !strncmp(src_ptr, option, optlen) &&
|
||||
(*(src_ptr + optlen) == '=' ||
|
||||
my_isspace(&my_charset_latin1, *(src_ptr + optlen)) ||
|
||||
*(src_ptr + optlen) == '\0'))
|
||||
{
|
||||
/* The option under modifying was found in this section. Apply new. */
|
||||
if (!remove_option)
|
||||
dst_ptr= strmov(dst_ptr, tmp);
|
||||
tmp_ptr= 0; /* To mark that we have already applied this */
|
||||
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
|
||||
opt_applied= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* If going to new group and we have option to apply, do it now */
|
||||
if (tmp_ptr && *src_ptr == '[')
|
||||
if (in_section && !opt_applied && *src_ptr == '[')
|
||||
{
|
||||
dst_ptr= strmov(dst_ptr, tmp);
|
||||
tmp_ptr= 0;
|
||||
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
|
||||
|
||||
}
|
||||
for (; nr_newlines; nr_newlines--)
|
||||
dst_ptr= strmov(dst_ptr, NEWLINE);
|
||||
dst_ptr= strmov(dst_ptr, linebuff);
|
||||
}
|
||||
/* Look for a section */
|
||||
|
@ -117,43 +127,38 @@ int modify_defaults_file(const char *file_location, const char *option,
|
|||
|
||||
if (*src_ptr != ']')
|
||||
continue; /* Missing closing parenthesis. Assume this was no group */
|
||||
|
||||
in_section= TRUE;
|
||||
/* add option */
|
||||
if (!remove_option)
|
||||
{
|
||||
tmp_ptr= strmov(tmp, option);
|
||||
if (*option_value)
|
||||
{
|
||||
*tmp_ptr++= '=';
|
||||
tmp_ptr= strmov(tmp_ptr, option_value);
|
||||
}
|
||||
/* add a newline */
|
||||
strmov(tmp_ptr, NEWLINE);
|
||||
}
|
||||
}
|
||||
else
|
||||
in_section= FALSE; /* mark that this section is of no interest to us */
|
||||
}
|
||||
}
|
||||
/* File ended. New option still remains to apply at the end */
|
||||
if (tmp_ptr)
|
||||
/* File ended. */
|
||||
if (!opt_applied && !remove_option && in_section)
|
||||
{
|
||||
/* New option still remains to apply at the end */
|
||||
if (*(dst_ptr - 1) != '\n')
|
||||
*dst_ptr++= '\n';
|
||||
dst_ptr= strmov(dst_ptr, tmp);
|
||||
dst_ptr= strmov(dst_ptr, NEWLINE);
|
||||
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
|
||||
opt_applied= 1;
|
||||
}
|
||||
for (; nr_newlines; nr_newlines--)
|
||||
dst_ptr= strmov(dst_ptr, NEWLINE);
|
||||
|
||||
if (my_chsize(fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0,
|
||||
MYF(MY_WME)) ||
|
||||
my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) ||
|
||||
my_fwrite(cnf_file, file_buffer, (uint) (dst_ptr - file_buffer),
|
||||
MYF(MY_NABP)) ||
|
||||
my_fclose(cnf_file, MYF(MY_WME)))
|
||||
goto err;
|
||||
if (opt_applied)
|
||||
{
|
||||
/* Don't write the file if there are no changes to be made */
|
||||
if (my_chsize(fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0,
|
||||
MYF(MY_WME)) ||
|
||||
my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) ||
|
||||
my_fwrite(cnf_file, file_buffer, (uint) (dst_ptr - file_buffer),
|
||||
MYF(MY_NABP)))
|
||||
goto err;
|
||||
}
|
||||
if (my_fclose(cnf_file, MYF(MY_WME)))
|
||||
goto err;
|
||||
|
||||
my_free(file_buffer, MYF(0));
|
||||
|
||||
DBUG_RETURN(0);
|
||||
|
||||
err:
|
||||
|
@ -162,3 +167,21 @@ malloc_err:
|
|||
my_fclose(cnf_file, MYF(0));
|
||||
DBUG_RETURN(1); /* out of resources */
|
||||
}
|
||||
|
||||
|
||||
static char *add_option(char *dst, const char *option_value,
|
||||
const char *option, int remove_option)
|
||||
{
|
||||
if (!remove_option)
|
||||
{
|
||||
dst= strmov(dst, option);
|
||||
if (*option_value)
|
||||
{
|
||||
*dst++= '=';
|
||||
dst= strmov(dst, option_value);
|
||||
}
|
||||
/* add a newline */
|
||||
dst= strmov(dst, NEWLINE);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
|
|
@ -158,32 +158,52 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags)
|
|||
DBUG_RETURN(fd);
|
||||
} /* my_fdopen */
|
||||
|
||||
/*
|
||||
make_ftype
|
||||
Make a filehandler-open-typestring from ordinary inputflags
|
||||
|
||||
/* Make a filehandler-open-typestring from ordinary inputflags */
|
||||
|
||||
Note: This routine attempts to find the best possible match
|
||||
between a numeric option and a string option that could be
|
||||
fed to fopen. There is not a 1 to 1 mapping between the two.
|
||||
|
||||
r == O_RDONLY
|
||||
w == O_WRONLY|O_TRUNC|O_CREAT
|
||||
a == O_WRONLY|O_APPEND|O_CREAT
|
||||
r+ == O_RDWR
|
||||
w+ == O_RDWR|O_TRUNC|O_CREAT
|
||||
a+ == O_RDWR|O_APPEND|O_CREAT
|
||||
*/
|
||||
static void make_ftype(register my_string to, register int flag)
|
||||
{
|
||||
#if FILE_BINARY /* If we have binary-files */
|
||||
#if FILE_BINARY
|
||||
/* If we have binary-files */
|
||||
reg3 int org_flag=flag;
|
||||
#endif
|
||||
flag&= ~FILE_BINARY; /* remove binary bit */
|
||||
if (flag == O_RDONLY)
|
||||
*to++= 'r';
|
||||
else if (flag == O_WRONLY)
|
||||
*to++= 'w';
|
||||
else
|
||||
{ /* Add '+' after theese */
|
||||
if (flag == O_RDWR)
|
||||
#endif
|
||||
flag&= ~FILE_BINARY; /* remove binary bit */
|
||||
|
||||
/* check some possible invalid combinations */
|
||||
DBUG_ASSERT(flag & (O_TRUNC|O_APPEND) != O_TRUNC|O_APPEND);
|
||||
|
||||
if (flag & (O_RDONLY|O_WRONLY) == O_WRONLY)
|
||||
*to++= (flag & O_APPEND) ? 'a' : 'w';
|
||||
else if (flag & O_RDWR)
|
||||
{
|
||||
/* Add '+' after theese */
|
||||
if (flag & (O_TRUNC | O_CREAT))
|
||||
*to++= 'w';
|
||||
else if (flag & O_APPEND)
|
||||
*to++= 'a';
|
||||
else
|
||||
*to++= 'r';
|
||||
else if (flag & O_APPEND)
|
||||
*to++= 'a';
|
||||
else
|
||||
*to++= 'w'; /* Create file */
|
||||
*to++= '+';
|
||||
}
|
||||
#if FILE_BINARY /* If we have binary-files */
|
||||
if (org_flag & FILE_BINARY)
|
||||
*to++= '+';
|
||||
}
|
||||
else
|
||||
*to++= 'r';
|
||||
|
||||
#if FILE_BINARY /* If we have binary-files */
|
||||
if (org_flag & FILE_BINARY)
|
||||
*to++='b';
|
||||
#endif
|
||||
#endif
|
||||
*to='\0';
|
||||
} /* make_ftype */
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ save_args=$*
|
|||
VERSION="ndb-autotest.sh version 1.04"
|
||||
|
||||
DATE=`date '+%Y-%m-%d'`
|
||||
HOST=`hostname -s`
|
||||
HOST=`hostname`
|
||||
export DATE HOST
|
||||
|
||||
set -e
|
||||
|
@ -330,7 +330,10 @@ start(){
|
|||
tar cfz /tmp/res.$2.$$.tgz `basename $p2`/$DATE
|
||||
scp /tmp/res.$2.$$.tgz \
|
||||
$result_host:$result_path/res.$DATE.$HOST.$2.$$.tgz
|
||||
rm -f /tmp/res.$2.$$.tgz
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
rm -f /tmp/res.$2.$$.tgz
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
|
@ -1616,7 +1616,10 @@ bool sys_var::check_set(THD *thd, set_var *var, TYPELIB *enum_names)
|
|||
if (var->value->result_type() == STRING_RESULT)
|
||||
{
|
||||
if (!(res= var->value->val_str(&str)))
|
||||
{
|
||||
strmake(buff, "NULL", 4);
|
||||
goto err;
|
||||
}
|
||||
var->save_result.ulong_value= ((ulong)
|
||||
find_set(enum_names, res->c_ptr(),
|
||||
res->length(),
|
||||
|
|
|
@ -188,7 +188,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
|
|||
ACL_HOST host;
|
||||
update_hostname(&host.host,get_field(&mem, table->field[0]));
|
||||
host.db= get_field(&mem, table->field[1]);
|
||||
if (lower_case_table_names)
|
||||
if (lower_case_table_names && host.db)
|
||||
{
|
||||
/*
|
||||
convert db to lower case and give a warning if the db wasn't
|
||||
|
@ -210,7 +210,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
|
|||
{
|
||||
sql_print_warning("'host' entry '%s|%s' "
|
||||
"ignored in --skip-name-resolve mode.",
|
||||
host.host.hostname, host.db, host.host.hostname);
|
||||
host.host.hostname, host.db?host.db:"");
|
||||
continue;
|
||||
}
|
||||
#ifndef TO_BE_REMOVED
|
||||
|
@ -278,7 +278,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
|
|||
{
|
||||
sql_print_warning("'user' entry '%s@%s' "
|
||||
"ignored in --skip-name-resolve mode.",
|
||||
user.user, user.host.hostname, user.host.hostname);
|
||||
user.user, user.host.hostname);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -414,7 +414,7 @@ my_bool acl_init(THD *org_thd, bool dont_read_acl_tables)
|
|||
{
|
||||
sql_print_warning("'db' entry '%s %s@%s' "
|
||||
"ignored in --skip-name-resolve mode.",
|
||||
db.db, db.user, db.host.hostname, db.host.hostname);
|
||||
db.db, db.user, db.host.hostname);
|
||||
continue;
|
||||
}
|
||||
db.access=get_access(table,3);
|
||||
|
@ -3232,7 +3232,7 @@ my_bool grant_init(THD *org_thd)
|
|||
sql_print_warning("'procs_priv' entry '%s %s@%s' "
|
||||
"ignored in --skip-name-resolve mode.",
|
||||
mem_check->tname, mem_check->user,
|
||||
mem_check->host, mem_check->host);
|
||||
mem_check->host);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -413,8 +413,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
|||
cond->fix_fields(thd, tables, &cond)) || cond->check_cols(1)))
|
||||
goto err0;
|
||||
|
||||
table->file->init_table_handle_for_HANDLER(); // Only InnoDB requires it
|
||||
|
||||
if (keyname)
|
||||
{
|
||||
if ((keyno=find_type(keyname, &table->s->keynames, 1+2)-1)<0)
|
||||
|
@ -422,8 +420,6 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
|||
my_error(ER_KEY_DOES_NOT_EXITS, MYF(0), keyname, tables->alias);
|
||||
goto err0;
|
||||
}
|
||||
table->file->ha_index_or_rnd_end();
|
||||
table->file->ha_index_init(keyno);
|
||||
}
|
||||
|
||||
if (insert_fields(thd, tables, tables->db, tables->alias, &it, 0, 0))
|
||||
|
@ -449,9 +445,22 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
|||
for (num_rows=0; num_rows < select_limit_cnt; )
|
||||
{
|
||||
switch (mode) {
|
||||
case RNEXT:
|
||||
if (table->file->inited != handler::NONE)
|
||||
{
|
||||
error=keyname ?
|
||||
table->file->index_next(table->record[0]) :
|
||||
table->file->rnd_next(table->record[0]);
|
||||
break;
|
||||
}
|
||||
/* else fall through */
|
||||
case RFIRST:
|
||||
if (keyname)
|
||||
{
|
||||
table->file->ha_index_or_rnd_end();
|
||||
table->file->ha_index_init(keyno);
|
||||
error= table->file->index_first(table->record[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
table->file->ha_index_or_rnd_end();
|
||||
|
@ -460,19 +469,20 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
|||
}
|
||||
mode=RNEXT;
|
||||
break;
|
||||
case RLAST:
|
||||
DBUG_ASSERT(keyname != 0);
|
||||
error= table->file->index_last(table->record[0]);
|
||||
mode=RPREV;
|
||||
break;
|
||||
case RNEXT:
|
||||
error= (keyname ?
|
||||
table->file->index_next(table->record[0]) :
|
||||
table->file->rnd_next(table->record[0]));
|
||||
break;
|
||||
case RPREV:
|
||||
DBUG_ASSERT(keyname != 0);
|
||||
error= table->file->index_prev(table->record[0]);
|
||||
if (table->file->inited != handler::NONE)
|
||||
{
|
||||
error=table->file->index_prev(table->record[0]);
|
||||
break;
|
||||
}
|
||||
/* else fall through */
|
||||
case RLAST:
|
||||
DBUG_ASSERT(keyname != 0);
|
||||
table->file->ha_index_or_rnd_end();
|
||||
table->file->ha_index_init(keyno);
|
||||
error= table->file->index_last(table->record[0]);
|
||||
mode=RPREV;
|
||||
break;
|
||||
case RNEXT_SAME:
|
||||
/* Continue scan on "(keypart1,keypart2,...)=(c1, c2, ...) */
|
||||
|
@ -508,6 +518,8 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables,
|
|||
}
|
||||
if (!(key= (byte*) thd->calloc(ALIGN_SIZE(key_len))))
|
||||
goto err;
|
||||
table->file->ha_index_or_rnd_end();
|
||||
table->file->ha_index_init(keyno);
|
||||
key_copy(key, table->record[0], table->key_info + keyno, key_len);
|
||||
error= table->file->index_read(table->record[0],
|
||||
key,key_len,ha_rkey_mode);
|
||||
|
|
|
@ -2589,28 +2589,33 @@ bool mysql_create_like_table(THD* thd, TABLE_LIST* table,
|
|||
char src_path[FN_REFLEN], dst_path[FN_REFLEN];
|
||||
char *db= table->db;
|
||||
char *table_name= table->table_name;
|
||||
char *src_db= thd->db;
|
||||
char *src_db;
|
||||
char *src_table= table_ident->table.str;
|
||||
int err;
|
||||
bool res= TRUE;
|
||||
TABLE_LIST src_tables_list;
|
||||
DBUG_ENTER("mysql_create_like_table");
|
||||
src_db= table_ident->db.str ? table_ident->db.str : thd->db;
|
||||
|
||||
/*
|
||||
Validate the source table
|
||||
*/
|
||||
if (table_ident->table.length > NAME_LEN ||
|
||||
(table_ident->table.length &&
|
||||
check_table_name(src_table,table_ident->table.length)) ||
|
||||
table_ident->db.str && check_db_name((src_db= table_ident->db.str)))
|
||||
check_table_name(src_table,table_ident->table.length)))
|
||||
{
|
||||
my_error(ER_WRONG_TABLE_NAME, MYF(0), src_table);
|
||||
DBUG_RETURN(TRUE);
|
||||
}
|
||||
if (!src_db || check_db_name(src_db))
|
||||
{
|
||||
my_error(ER_WRONG_DB_NAME, MYF(0), src_db ? src_db : "NULL");
|
||||
DBUG_RETURN(-1);
|
||||
}
|
||||
|
||||
bzero((gptr)&src_tables_list, sizeof(src_tables_list));
|
||||
src_tables_list.db= table_ident->db.str ? table_ident->db.str : thd->db;
|
||||
src_tables_list.table_name= table_ident->table.str;
|
||||
src_tables_list.db= src_db;
|
||||
src_tables_list.table_name= src_table;
|
||||
|
||||
if (lock_and_wait_for_table_name(thd, &src_tables_list))
|
||||
goto err;
|
||||
|
|
Loading…
Add table
Reference in a new issue