mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
manually merged
This commit is contained in:
@ -51774,6 +51774,8 @@ not yet 100% confident in this code.
|
||||
Allow one to start multiple MySQL servers on windows (code backported
|
||||
from 4.0.2).
|
||||
@item
|
||||
Fixed that @code{--core-file} works on Linux (at least on kernel 2.4.18).
|
||||
@item
|
||||
Fixed a problem with BDB and @code{ALTER TABLE}.
|
||||
@item
|
||||
Fixed reference to freed memory when doing complicated @code{GROUP BY
|
||||
@ -51859,6 +51861,11 @@ Changed initialisation of @code{RND()} to make it less predicatable.
|
||||
Fixed problem with @code{GROUP BY} on result with expression that created a
|
||||
@code{BLOB} field.
|
||||
@item
|
||||
Fixed problem with @code{GROUP BY} on columns that have NULL values. To
|
||||
solve this we now create an MyISAM temporary table when doing a group by
|
||||
on a possible NULL item. In MySQL 4.0.5 we can again use in memory HEAP
|
||||
tables for this case.
|
||||
@item
|
||||
Fixed problem with privilege tables when downgrading from 4.0.2 to 3.23.
|
||||
@item
|
||||
Fixed thread bug in @code{SLAVE START}, @code{SLAVE STOP} and automatic repair
|
||||
|
73
dbug/dbug_add_tags.pl
Executable file
73
dbug/dbug_add_tags.pl
Executable file
@ -0,0 +1,73 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
die "No files specified\n" unless $ARGV[0];
|
||||
|
||||
$ctags="exctags -x -f - --c-types=f -u";
|
||||
|
||||
sub get_tag {
|
||||
local $.; local $_=<TAGS>;
|
||||
($symbol, $line)= /^(.*\S)\s+function\s+(\d+)/;
|
||||
$symbol=$1 if /\s(\S+)\s*\(/;
|
||||
$line=1e50 unless $line;
|
||||
}
|
||||
|
||||
while($src=shift)
|
||||
{
|
||||
warn "==> $src\n";
|
||||
|
||||
$dst=$src.$$;
|
||||
open(TAGS, "$ctags $src|") || die "Cannot exec('$ctags $src'): $!";
|
||||
open(SRC, "<$src") || die "Cannot open $src: $!";
|
||||
open(DST, ">$dst") || die "Cannot create $dst: $!";
|
||||
select DST;
|
||||
|
||||
&get_tag;
|
||||
$in_func=0;
|
||||
while(<SRC>)
|
||||
{
|
||||
my $orig=$_;
|
||||
if ($in_func)
|
||||
{
|
||||
if (/\breturn\b/ && !/\/\*.*\breturn\b.*\*\// && !/;/ )
|
||||
{
|
||||
$_.=<SRC> until /;/;
|
||||
}
|
||||
s/(?<=\s)return\s*;/DBUG_VOID_RETURN;/;
|
||||
s/(?<=\s)return\s*(.+)\s*;/DBUG_RETURN(\1);/s;
|
||||
$ret_line=$. if /DBUG_(VOID_)?RETURN/; #{{
|
||||
print "$tab DBUG_VOID_RETURN;\n" if /^$tab}/ && $ret_line < $.-1;
|
||||
$in_func=0 if /^$tab}/;
|
||||
warn "$src:".($.-1)."\t$orig" if /\breturn\b/;
|
||||
}
|
||||
print;
|
||||
next if $. < $line;
|
||||
die "Something wrong: \$.=$., \$line=$line, \$symbol=$symbol\n" if $. > $line;
|
||||
&get_tag && next if /^\s*inline /;
|
||||
print $_=<SRC> until /{/; $tab=$`;
|
||||
&get_tag && next if /}/; # skip one-liners
|
||||
$semicolon=1;
|
||||
while(<SRC>)
|
||||
{
|
||||
$skip=!$semicolon;
|
||||
$semicolon= /;\s*$/;
|
||||
print && next if $skip ||
|
||||
(/^\s+\w+((::\w+)?|<\w+>)\s+\**\w+/ && !/^\s*return/);
|
||||
last if /DBUG_ENTER/;
|
||||
print "$tab DBUG_ENTER(\"$symbol\");\n";
|
||||
print "\n" unless $_ eq "\n";
|
||||
last;
|
||||
}
|
||||
$in_func=1;
|
||||
&get_tag;
|
||||
redo;
|
||||
}
|
||||
close SRC;
|
||||
close DST;
|
||||
close TAGS;
|
||||
unlink("$src.orig");
|
||||
rename($src, "$src.orig") || die "Cannot rename $src to $src.orig: $!";
|
||||
rename($dst, $src) || die "Cannot rename $dst to $src: $!";
|
||||
}
|
||||
|
||||
warn "All done!\n";
|
||||
|
@ -154,7 +154,8 @@ static int walk_and_match(FT_WORD *word, uint32 count, ALL_IN_ONE *aio)
|
||||
if (doc_cnt)
|
||||
{
|
||||
word->weight*=GWS_IN_USE;
|
||||
if (word->weight < 0) word->weight=0;
|
||||
if (word->weight < 0)
|
||||
word->weight=0;
|
||||
|
||||
}
|
||||
DBUG_RETURN(0);
|
||||
|
@ -380,6 +380,7 @@ CREATE TABLE t3 (ctime1 char(19) NOT NULL, ctime2 char(19) NOT NULL);
|
||||
INSERT INTO t3 VALUES ("2002-10-29 16:51:06","2002-11-05 16:47:31");
|
||||
select * from t1, t2 where t1.start between t2.ctime1 and t2.ctime2;
|
||||
start ctime1 ctime2
|
||||
2002-11-04 00:00:00 20021029165106 20021105164731
|
||||
select * from t1, t2 where t1.start >= t2.ctime1 and t1.start <= t2.ctime2;
|
||||
start ctime1 ctime2
|
||||
2002-11-04 00:00:00 20021029165106 20021105164731
|
||||
|
@ -541,3 +541,23 @@ select max(b) from t1 where a = 2;
|
||||
max(b)
|
||||
1
|
||||
drop table if exists t,t1,t2;
|
||||
drop table if exists t1, t2, t3, t4, t5, t6;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
insert into t1 values (1);
|
||||
insert into t2 values (2);
|
||||
create temporary table t3 (a int not null) TYPE=MERGE UNION=(t1,t2);
|
||||
select * from t3;
|
||||
a
|
||||
1
|
||||
2
|
||||
create temporary table t4 (a int not null);
|
||||
create temporary table t5 (a int not null);
|
||||
insert into t4 values (1);
|
||||
insert into t5 values (2);
|
||||
create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
|
||||
select * from t6;
|
||||
a
|
||||
1
|
||||
2
|
||||
drop table if exists t1, t2, t3, t4, t5, t6;
|
||||
|
@ -185,3 +185,22 @@ CREATE TABLE t ( a int(11) NOT NULL default '0', b int(11) NOT NULL default '0
|
||||
select max(b) from t where a = 2;
|
||||
select max(b) from t1 where a = 2;
|
||||
drop table if exists t,t1,t2;
|
||||
|
||||
#
|
||||
# temporary merge tables
|
||||
#
|
||||
drop table if exists t1, t2, t3, t4, t5, t6;
|
||||
create table t1 (a int not null);
|
||||
create table t2 (a int not null);
|
||||
insert into t1 values (1);
|
||||
insert into t2 values (2);
|
||||
create temporary table t3 (a int not null) TYPE=MERGE UNION=(t1,t2);
|
||||
select * from t3;
|
||||
create temporary table t4 (a int not null);
|
||||
create temporary table t5 (a int not null);
|
||||
insert into t4 values (1);
|
||||
insert into t5 values (2);
|
||||
create temporary table t6 (a int not null) TYPE=MERGE UNION=(t4,t5);
|
||||
select * from t6;
|
||||
drop table if exists t1, t2, t3, t4, t5, t6;
|
||||
|
||||
|
209
sql/ha_myisam.cc
209
sql/ha_myisam.cc
@ -48,6 +48,8 @@ TYPELIB myisam_recover_typelib= {array_elements(myisam_recover_names)-1,"",
|
||||
static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
|
||||
const char *fmt, va_list args)
|
||||
{
|
||||
DBUG_ENTER("mi_check_print_msg");
|
||||
|
||||
THD* thd = (THD*)param->thd;
|
||||
String* packet = &thd->packet;
|
||||
uint length;
|
||||
@ -64,12 +66,12 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
|
||||
if (thd->net.vio == 0)
|
||||
{
|
||||
sql_print_error(msgbuf);
|
||||
return;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
if (param->testflag & (T_CREATE_MISSING_KEYS | T_SAFE_REPAIR | T_AUTO_REPAIR))
|
||||
{
|
||||
my_message(ER_NOT_KEYFILE,msgbuf,MYF(MY_WME));
|
||||
return;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
length=(uint) (strxmov(name, param->db_name,".",param->table_name,NullS) -
|
||||
name);
|
||||
@ -81,37 +83,46 @@ static void mi_check_print_msg(MI_CHECK *param, const char* msg_type,
|
||||
if (my_net_write(&thd->net, (char*)thd->packet.ptr(), thd->packet.length()))
|
||||
sql_print_error("Failed on my_net_write, writing to stderr instead: %s\n",
|
||||
msgbuf);
|
||||
return;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
void mi_check_print_error(MI_CHECK *param, const char *fmt,...)
|
||||
{
|
||||
DBUG_ENTER("mi_check_print_error");
|
||||
|
||||
param->error_printed|=1;
|
||||
param->out_flag|= O_DATA_LOST;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
mi_check_print_msg(param, "error", fmt, args);
|
||||
va_end(args);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
void mi_check_print_info(MI_CHECK *param, const char *fmt,...)
|
||||
{
|
||||
va_list args;
|
||||
DBUG_ENTER("mi_check_print_info");
|
||||
|
||||
va_start(args, fmt);
|
||||
mi_check_print_msg(param, "info", fmt, args);
|
||||
va_end(args);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
void mi_check_print_warning(MI_CHECK *param, const char *fmt,...)
|
||||
{
|
||||
DBUG_ENTER("mi_check_print_warning");
|
||||
|
||||
param->warning_printed=1;
|
||||
param->out_flag|= O_DATA_LOST;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
mi_check_print_msg(param, "warning", fmt, args);
|
||||
va_end(args);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
}
|
||||
@ -122,15 +133,18 @@ const char **ha_myisam::bas_ext() const
|
||||
|
||||
const char *ha_myisam::index_type(uint key_number)
|
||||
{
|
||||
return ((table->key_info[key_number].flags & HA_FULLTEXT) ?
|
||||
DBUG_ENTER("*ha_myisam::index_type");
|
||||
|
||||
DBUG_RETURN(((table->key_info[key_number].flags & HA_FULLTEXT) ?
|
||||
"FULLTEXT" :
|
||||
"BTREE");
|
||||
"BTREE"));
|
||||
}
|
||||
|
||||
int ha_myisam::net_read_dump(NET* net)
|
||||
{
|
||||
int data_fd = file->dfile;
|
||||
int error = 0;
|
||||
DBUG_ENTER("ha_myisam::net_read_dump");
|
||||
|
||||
my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
|
||||
for (;;)
|
||||
@ -153,12 +167,14 @@ int ha_myisam::net_read_dump(NET* net)
|
||||
}
|
||||
|
||||
err:
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
int ha_myisam::dump(THD* thd, int fd)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::dump");
|
||||
|
||||
MYISAM_SHARE* share = file->s;
|
||||
NET* net = &thd->net;
|
||||
uint blocksize = share->blocksize;
|
||||
@ -166,7 +182,7 @@ int ha_myisam::dump(THD* thd, int fd)
|
||||
int data_fd = file->dfile;
|
||||
byte * buf = (byte*) my_malloc(blocksize, MYF(MY_WME));
|
||||
if (!buf)
|
||||
return ENOMEM;
|
||||
DBUG_RETURN(ENOMEM);
|
||||
|
||||
int error = 0;
|
||||
my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
|
||||
@ -206,15 +222,17 @@ int ha_myisam::dump(THD* thd, int fd)
|
||||
|
||||
err:
|
||||
my_free((gptr) buf, MYF(0));
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
/* Name is here without an extension */
|
||||
|
||||
int ha_myisam::open(const char *name, int mode, uint test_if_locked)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::open");
|
||||
|
||||
if (!(file=mi_open(name, mode, test_if_locked)))
|
||||
return (my_errno ? my_errno : -1);
|
||||
DBUG_RETURN((my_errno ? my_errno : -1));
|
||||
|
||||
if (test_if_locked & (HA_OPEN_IGNORE_IF_LOCKED | HA_OPEN_TMP_TABLE))
|
||||
VOID(mi_extra(file, HA_EXTRA_NO_WAIT_LOCK, 0));
|
||||
@ -223,18 +241,22 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked)
|
||||
VOID(mi_extra(file, HA_EXTRA_WAIT_LOCK, 0));
|
||||
if (!table->db_record_offset)
|
||||
int_table_flags|=HA_REC_NOT_IN_SEQ;
|
||||
return (0);
|
||||
DBUG_RETURN((0));
|
||||
}
|
||||
|
||||
int ha_myisam::close(void)
|
||||
{
|
||||
MI_INFO *tmp=file;
|
||||
DBUG_ENTER("ha_myisam::close");
|
||||
|
||||
file=0;
|
||||
return mi_close(tmp);
|
||||
DBUG_RETURN(mi_close(tmp));
|
||||
}
|
||||
|
||||
int ha_myisam::write_row(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::write_row");
|
||||
|
||||
statistic_increment(ha_write_count,&LOCK_status);
|
||||
|
||||
/* If we have a timestamp column, update it to the current time */
|
||||
@ -248,12 +270,14 @@ int ha_myisam::write_row(byte * buf)
|
||||
*/
|
||||
if (table->next_number_field && buf == table->record[0])
|
||||
update_auto_increment();
|
||||
return mi_write(file,buf);
|
||||
DBUG_RETURN(mi_write(file,buf));
|
||||
}
|
||||
|
||||
int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
if (!file) return HA_ADMIN_INTERNAL_ERROR;
|
||||
DBUG_ENTER("ha_myisam::check");
|
||||
|
||||
if (!file) DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
|
||||
int error;
|
||||
MI_CHECK param;
|
||||
MYISAM_SHARE* share = file->s;
|
||||
@ -278,7 +302,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
share->state.open_count == 0) ||
|
||||
((param.testflag & T_FAST) && (share->state.open_count ==
|
||||
(uint) (share->global_changed ? 1 : 0)))))
|
||||
return HA_ADMIN_ALREADY_DONE;
|
||||
DBUG_RETURN(HA_ADMIN_ALREADY_DONE);
|
||||
|
||||
error = chk_status(¶m, file); // Not fatal
|
||||
error = chk_size(¶m, file);
|
||||
@ -331,7 +355,7 @@ int ha_myisam::check(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
}
|
||||
|
||||
thd->proc_info=old_proc_info;
|
||||
return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;
|
||||
DBUG_RETURN(error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK);
|
||||
}
|
||||
|
||||
|
||||
@ -345,6 +369,8 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
int error=0;
|
||||
MI_CHECK param;
|
||||
DBUG_ENTER("ha_myisam::analyze");
|
||||
|
||||
MYISAM_SHARE* share = file->s;
|
||||
|
||||
myisamchk_init(¶m);
|
||||
@ -357,7 +383,7 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
|
||||
param.using_global_keycache = 1;
|
||||
|
||||
if (!(share->state.changed & STATE_NOT_ANALYZED))
|
||||
return HA_ADMIN_ALREADY_DONE;
|
||||
DBUG_RETURN(HA_ADMIN_ALREADY_DONE);
|
||||
|
||||
error = chk_key(¶m, file);
|
||||
if (!error)
|
||||
@ -368,7 +394,7 @@ int ha_myisam::analyze(THD *thd, HA_CHECK_OPT* check_opt)
|
||||
}
|
||||
else if (!mi_is_crashed(file))
|
||||
mi_mark_crashed(file);
|
||||
return error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK;
|
||||
DBUG_RETURN(error ? HA_ADMIN_CORRUPT : HA_ADMIN_OK);
|
||||
}
|
||||
|
||||
|
||||
@ -380,7 +406,7 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
char* table_name = table->real_name;
|
||||
int error;
|
||||
const char* errmsg;
|
||||
DBUG_ENTER("restore");
|
||||
DBUG_ENTER("ha_myisam::restore");
|
||||
|
||||
if (fn_format_relative_to_data_home(src_path, table_name, backup_dir,
|
||||
MI_NAME_DEXT))
|
||||
@ -399,7 +425,6 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
DBUG_RETURN(repair(thd, &tmp_check_opt));
|
||||
|
||||
err:
|
||||
{
|
||||
MI_CHECK param;
|
||||
myisamchk_init(¶m);
|
||||
param.thd = thd;
|
||||
@ -409,7 +434,6 @@ int ha_myisam::restore(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
param.testflag = 0;
|
||||
mi_check_print_error(¶m,errmsg, my_errno);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -460,7 +484,6 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
DBUG_RETURN(HA_ADMIN_OK);
|
||||
|
||||
err:
|
||||
{
|
||||
MI_CHECK param;
|
||||
myisamchk_init(¶m);
|
||||
param.thd = thd;
|
||||
@ -470,7 +493,6 @@ int ha_myisam::backup(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
param.testflag = 0;
|
||||
mi_check_print_error(¶m,errmsg, my_errno);
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -479,8 +501,9 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
int error;
|
||||
MI_CHECK param;
|
||||
ha_rows start_records;
|
||||
DBUG_ENTER("ha_myisam::repair");
|
||||
|
||||
if (!file) return HA_ADMIN_INTERNAL_ERROR;
|
||||
if (!file) DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
|
||||
|
||||
myisamchk_init(¶m);
|
||||
param.thd = thd;
|
||||
@ -520,12 +543,14 @@ int ha_myisam::repair(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
llstr(start_records, llbuff2),
|
||||
table->path);
|
||||
}
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
{
|
||||
if (!file) return HA_ADMIN_INTERNAL_ERROR;
|
||||
DBUG_ENTER("ha_myisam::optimize");
|
||||
|
||||
if (!file) DBUG_RETURN(HA_ADMIN_INTERNAL_ERROR);
|
||||
MI_CHECK param;
|
||||
|
||||
myisamchk_init(¶m);
|
||||
@ -534,7 +559,7 @@ int ha_myisam::optimize(THD* thd, HA_CHECK_OPT *check_opt)
|
||||
param.testflag = (check_opt->flags | T_SILENT | T_FORCE_CREATE |
|
||||
T_REP_BY_SORT | T_STATISTICS | T_SORT_INDEX);
|
||||
param.sort_buffer_length= check_opt->sort_buffer_size;
|
||||
return repair(thd,param,1);
|
||||
DBUG_RETURN(repair(thd,param,1));
|
||||
}
|
||||
|
||||
|
||||
@ -669,6 +694,8 @@ int ha_myisam::repair(THD *thd, MI_CHECK ¶m, bool optimize)
|
||||
|
||||
void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::deactivate_non_unique_index");
|
||||
|
||||
MYISAM_SHARE* share = file->s;
|
||||
if (share->state.key_map == ((ulonglong) 1L << share->base.keys)-1)
|
||||
{
|
||||
@ -690,6 +717,7 @@ void ha_myisam::deactivate_non_unique_index(ha_rows rows)
|
||||
}
|
||||
else
|
||||
enable_activate_all_index=0;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
@ -698,7 +726,7 @@ bool ha_myisam::activate_all_index(THD *thd)
|
||||
int error=0;
|
||||
MI_CHECK param;
|
||||
MYISAM_SHARE* share = file->s;
|
||||
DBUG_ENTER("activate_all_index");
|
||||
DBUG_ENTER("ha_myisam::activate_all_index");
|
||||
|
||||
mi_extra(file, HA_EXTRA_BULK_INSERT_END, 0);
|
||||
table->bulk_insert= 0;
|
||||
@ -752,131 +780,165 @@ bool ha_myisam::check_and_repair(THD *thd)
|
||||
|
||||
bool ha_myisam::is_crashed() const
|
||||
{
|
||||
return (file->s->state.changed & STATE_CRASHED ||
|
||||
(my_disable_locking && file->s->state.open_count));
|
||||
DBUG_ENTER("ha_myisam::is_crashed");
|
||||
|
||||
DBUG_RETURN((file->s->state.changed & STATE_CRASHED ||
|
||||
(my_disable_locking && file->s->state.open_count)));
|
||||
}
|
||||
|
||||
int ha_myisam::update_row(const byte * old_data, byte * new_data)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::update_row");
|
||||
|
||||
statistic_increment(ha_update_count,&LOCK_status);
|
||||
if (table->time_stamp)
|
||||
update_timestamp(new_data+table->time_stamp-1);
|
||||
return mi_update(file,old_data,new_data);
|
||||
DBUG_RETURN(mi_update(file,old_data,new_data));
|
||||
}
|
||||
|
||||
int ha_myisam::delete_row(const byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::delete_row");
|
||||
|
||||
statistic_increment(ha_delete_count,&LOCK_status);
|
||||
return mi_delete(file,buf);
|
||||
DBUG_RETURN(mi_delete(file,buf));
|
||||
}
|
||||
|
||||
int ha_myisam::index_read(byte * buf, const byte * key,
|
||||
uint key_len, enum ha_rkey_function find_flag)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_read");
|
||||
|
||||
statistic_increment(ha_read_key_count,&LOCK_status);
|
||||
int error=mi_rkey(file,buf,active_index, key, key_len, find_flag);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::index_read_idx(byte * buf, uint index, const byte * key,
|
||||
uint key_len, enum ha_rkey_function find_flag)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_read_idx");
|
||||
|
||||
statistic_increment(ha_read_key_count,&LOCK_status);
|
||||
int error=mi_rkey(file,buf,index, key, key_len, find_flag);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::index_read_last(byte * buf, const byte * key, uint key_len)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_read_last");
|
||||
|
||||
statistic_increment(ha_read_key_count,&LOCK_status);
|
||||
int error=mi_rkey(file,buf,active_index, key, key_len, HA_READ_PREFIX_LAST);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::index_next(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_next");
|
||||
|
||||
statistic_increment(ha_read_next_count,&LOCK_status);
|
||||
int error=mi_rnext(file,buf,active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::index_prev(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_prev");
|
||||
|
||||
statistic_increment(ha_read_prev_count,&LOCK_status);
|
||||
int error=mi_rprev(file,buf, active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::index_first(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_first");
|
||||
|
||||
statistic_increment(ha_read_first_count,&LOCK_status);
|
||||
int error=mi_rfirst(file, buf, active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::index_last(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_last");
|
||||
|
||||
statistic_increment(ha_read_last_count,&LOCK_status);
|
||||
int error=mi_rlast(file, buf, active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::index_next_same(byte * buf,
|
||||
const byte *key __attribute__((unused)),
|
||||
uint length __attribute__((unused)))
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::index_next_same");
|
||||
|
||||
statistic_increment(ha_read_next_count,&LOCK_status);
|
||||
int error=mi_rnext_same(file,buf);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
int ha_myisam::rnd_init(bool scan)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::rnd_init");
|
||||
|
||||
if (scan)
|
||||
return mi_scan_init(file);
|
||||
return mi_extra(file, HA_EXTRA_RESET, 0);
|
||||
DBUG_RETURN(mi_scan_init(file));
|
||||
DBUG_RETURN(mi_extra(file, HA_EXTRA_RESET, 0));
|
||||
}
|
||||
|
||||
int ha_myisam::rnd_next(byte *buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::rnd_next");
|
||||
|
||||
statistic_increment(ha_read_rnd_next_count,&LOCK_status);
|
||||
int error=mi_scan(file, buf);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisam::restart_rnd_next(byte *buf, byte *pos)
|
||||
{
|
||||
return rnd_pos(buf,pos);
|
||||
DBUG_ENTER("ha_myisam::restart_rnd_next");
|
||||
|
||||
DBUG_RETURN(rnd_pos(buf,pos));
|
||||
}
|
||||
|
||||
int ha_myisam::rnd_pos(byte * buf, byte *pos)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::rnd_pos");
|
||||
|
||||
statistic_increment(ha_read_rnd_count,&LOCK_status);
|
||||
int error=mi_rrnd(file, buf, ha_get_ptr(pos,ref_length));
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
void ha_myisam::position(const byte* record)
|
||||
{
|
||||
my_off_t position=mi_position(file);
|
||||
DBUG_ENTER("ha_myisam::position");
|
||||
|
||||
ha_store_ptr(ref, ref_length, position);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
void ha_myisam::info(uint flag)
|
||||
{
|
||||
MI_ISAMINFO info;
|
||||
char name_buff[FN_REFLEN];
|
||||
DBUG_ENTER("ha_myisam::info");
|
||||
|
||||
(void) mi_status(file,&info,flag);
|
||||
if (flag & HA_STATUS_VARIABLE)
|
||||
@ -930,14 +992,17 @@ void ha_myisam::info(uint flag)
|
||||
update_time = info.update_time;
|
||||
if (flag & HA_STATUS_AUTO)
|
||||
auto_increment_value= info.auto_increment;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
int ha_myisam::extra(enum ha_extra_function operation)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::extra");
|
||||
|
||||
if ((specialflag & SPECIAL_SAFE_MODE) && operation == HA_EXTRA_KEYREAD)
|
||||
return 0;
|
||||
return mi_extra(file, operation, 0);
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(mi_extra(file, operation, 0));
|
||||
}
|
||||
|
||||
|
||||
@ -945,34 +1010,44 @@ int ha_myisam::extra(enum ha_extra_function operation)
|
||||
|
||||
int ha_myisam::extra_opt(enum ha_extra_function operation, ulong cache_size)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::extra_opt");
|
||||
|
||||
if ((specialflag & SPECIAL_SAFE_MODE) &
|
||||
(operation == HA_EXTRA_WRITE_CACHE ||
|
||||
operation == HA_EXTRA_BULK_INSERT_BEGIN))
|
||||
return 0;
|
||||
return mi_extra(file, operation, (void*) &cache_size);
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(mi_extra(file, operation, (void*) &cache_size));
|
||||
}
|
||||
|
||||
|
||||
int ha_myisam::reset(void)
|
||||
{
|
||||
return mi_extra(file, HA_EXTRA_RESET, 0);
|
||||
DBUG_ENTER("ha_myisam::reset");
|
||||
|
||||
DBUG_RETURN(mi_extra(file, HA_EXTRA_RESET, 0));
|
||||
}
|
||||
|
||||
int ha_myisam::delete_all_rows()
|
||||
{
|
||||
return mi_delete_all_rows(file);
|
||||
DBUG_ENTER("ha_myisam::delete_all_rows");
|
||||
|
||||
DBUG_RETURN(mi_delete_all_rows(file));
|
||||
}
|
||||
|
||||
int ha_myisam::delete_table(const char *name)
|
||||
{
|
||||
return mi_delete_table(name);
|
||||
DBUG_ENTER("ha_myisam::delete_table");
|
||||
|
||||
DBUG_RETURN(mi_delete_table(name));
|
||||
}
|
||||
|
||||
int ha_myisam::external_lock(THD *thd, int lock_type)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::external_lock");
|
||||
|
||||
if (!table->tmp_table)
|
||||
return mi_lock_database(file,lock_type);
|
||||
return 0;
|
||||
DBUG_RETURN(mi_lock_database(file,lock_type));
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
|
||||
@ -980,14 +1055,18 @@ THR_LOCK_DATA **ha_myisam::store_lock(THD *thd,
|
||||
THR_LOCK_DATA **to,
|
||||
enum thr_lock_type lock_type)
|
||||
{
|
||||
DBUG_ENTER("**ha_myisam::store_lock");
|
||||
|
||||
if (lock_type != TL_IGNORE && file->lock.type == TL_UNLOCK)
|
||||
file->lock.type=lock_type;
|
||||
*to++= &file->lock;
|
||||
return to;
|
||||
DBUG_RETURN(to);
|
||||
}
|
||||
|
||||
void ha_myisam::update_create_info(HA_CREATE_INFO *create_info)
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::update_create_info");
|
||||
|
||||
table->file->info(HA_STATUS_AUTO | HA_STATUS_CONST);
|
||||
if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
|
||||
{
|
||||
@ -1001,6 +1080,7 @@ void ha_myisam::update_create_info(HA_CREATE_INFO *create_info)
|
||||
}
|
||||
create_info->data_file_name=data_file_name;
|
||||
create_info->index_file_name=index_file_name;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
@ -1196,16 +1276,20 @@ int ha_myisam::create(const char *name, register TABLE *table_arg,
|
||||
|
||||
int ha_myisam::rename_table(const char * from, const char * to)
|
||||
{
|
||||
return mi_rename(from,to);
|
||||
DBUG_ENTER("ha_myisam::rename_table");
|
||||
|
||||
DBUG_RETURN(mi_rename(from,to));
|
||||
}
|
||||
|
||||
|
||||
longlong ha_myisam::get_auto_increment()
|
||||
{
|
||||
DBUG_ENTER("ha_myisam::get_auto_increment");
|
||||
|
||||
if (!table->next_number_key_offset)
|
||||
{ // Autoincrement at key-start
|
||||
ha_myisam::info(HA_STATUS_AUTO);
|
||||
return auto_increment_value;
|
||||
DBUG_RETURN(auto_increment_value);
|
||||
}
|
||||
|
||||
if (table->bulk_insert)
|
||||
@ -1226,7 +1310,7 @@ longlong ha_myisam::get_auto_increment()
|
||||
nr=(longlong)
|
||||
table->next_number_field->val_int_offset(table->rec_buff_length)+1;
|
||||
extra(HA_EXTRA_NO_KEYREAD);
|
||||
return nr;
|
||||
DBUG_RETURN(nr);
|
||||
}
|
||||
|
||||
|
||||
@ -1236,25 +1320,28 @@ ha_rows ha_myisam::records_in_range(int inx,
|
||||
const byte *end_key,uint end_key_len,
|
||||
enum ha_rkey_function end_search_flag)
|
||||
{
|
||||
return (ha_rows) mi_records_in_range(file,
|
||||
DBUG_ENTER("ha_myisam::records_in_range");
|
||||
|
||||
DBUG_RETURN((ha_rows) mi_records_in_range(file,
|
||||
inx,
|
||||
start_key,start_key_len,
|
||||
start_search_flag,
|
||||
end_key,end_key_len,
|
||||
end_search_flag);
|
||||
end_search_flag));
|
||||
}
|
||||
|
||||
int ha_myisam::ft_read(byte * buf)
|
||||
{
|
||||
int error;
|
||||
DBUG_ENTER("ha_myisam::ft_read");
|
||||
|
||||
if (!ft_handler)
|
||||
return -1;
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
thread_safe_increment(ha_read_next_count,&LOCK_status); // why ?
|
||||
|
||||
error=ft_handler->please->read_next(ft_handler,(char*) buf);
|
||||
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
@ -38,12 +38,14 @@ const char **ha_myisammrg::bas_ext() const
|
||||
int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
|
||||
{
|
||||
char name_buff[FN_REFLEN];
|
||||
DBUG_ENTER("ha_myisammrg::open");
|
||||
|
||||
DBUG_PRINT("info", ("ha_myisammrg::open"));
|
||||
if (!(file=myrg_open(fn_format(name_buff,name,"","",2 | 4), mode,
|
||||
test_if_locked)))
|
||||
{
|
||||
DBUG_PRINT("info", ("ha_myisammrg::open exit %d", my_errno));
|
||||
return (my_errno ? my_errno : -1);
|
||||
DBUG_RETURN((my_errno ? my_errno : -1));
|
||||
}
|
||||
DBUG_PRINT("info", ("ha_myisammrg::open myrg_extrafunc..."))
|
||||
myrg_extrafunc(file, query_cache_invalidate_by_MyISAM_filename_ref);
|
||||
@ -65,132 +67,165 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked)
|
||||
if (table->crashed)
|
||||
goto err;
|
||||
#endif
|
||||
return (0);
|
||||
DBUG_RETURN((0));
|
||||
err:
|
||||
myrg_close(file);
|
||||
file=0;
|
||||
return (my_errno= HA_ERR_WRONG_TABLE_DEF);
|
||||
DBUG_RETURN((my_errno= HA_ERR_WRONG_TABLE_DEF));
|
||||
}
|
||||
|
||||
int ha_myisammrg::close(void)
|
||||
{
|
||||
return myrg_close(file);
|
||||
DBUG_ENTER("ha_myisammrg::close");
|
||||
|
||||
DBUG_RETURN(myrg_close(file));
|
||||
}
|
||||
|
||||
int ha_myisammrg::write_row(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::write_row");
|
||||
|
||||
statistic_increment(ha_write_count,&LOCK_status);
|
||||
if (table->time_stamp)
|
||||
update_timestamp(buf+table->time_stamp-1);
|
||||
if (table->next_number_field && buf == table->record[0])
|
||||
update_auto_increment();
|
||||
return myrg_write(file,buf);
|
||||
DBUG_RETURN(myrg_write(file,buf));
|
||||
}
|
||||
|
||||
int ha_myisammrg::update_row(const byte * old_data, byte * new_data)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::update_row");
|
||||
|
||||
statistic_increment(ha_update_count,&LOCK_status);
|
||||
if (table->time_stamp)
|
||||
update_timestamp(new_data+table->time_stamp-1);
|
||||
return myrg_update(file,old_data,new_data);
|
||||
DBUG_RETURN(myrg_update(file,old_data,new_data));
|
||||
}
|
||||
|
||||
int ha_myisammrg::delete_row(const byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::delete_row");
|
||||
|
||||
statistic_increment(ha_delete_count,&LOCK_status);
|
||||
return myrg_delete(file,buf);
|
||||
DBUG_RETURN(myrg_delete(file,buf));
|
||||
}
|
||||
|
||||
int ha_myisammrg::index_read(byte * buf, const byte * key,
|
||||
uint key_len, enum ha_rkey_function find_flag)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::index_read");
|
||||
|
||||
statistic_increment(ha_read_key_count,&LOCK_status);
|
||||
int error=myrg_rkey(file,buf,active_index, key, key_len, find_flag);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key,
|
||||
uint key_len, enum ha_rkey_function find_flag)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::index_read_idx");
|
||||
|
||||
statistic_increment(ha_read_key_count,&LOCK_status);
|
||||
int error=myrg_rkey(file,buf,index, key, key_len, find_flag);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::index_read_last(byte * buf, const byte * key, uint key_len)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::index_read_last");
|
||||
|
||||
statistic_increment(ha_read_key_count,&LOCK_status);
|
||||
int error=myrg_rkey(file,buf,active_index, key, key_len,
|
||||
HA_READ_PREFIX_LAST);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::index_next(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::index_next");
|
||||
|
||||
statistic_increment(ha_read_next_count,&LOCK_status);
|
||||
int error=myrg_rnext(file,buf,active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::index_prev(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::index_prev");
|
||||
|
||||
statistic_increment(ha_read_prev_count,&LOCK_status);
|
||||
int error=myrg_rprev(file,buf, active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::index_first(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::index_first");
|
||||
|
||||
statistic_increment(ha_read_first_count,&LOCK_status);
|
||||
int error=myrg_rfirst(file, buf, active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::index_last(byte * buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::index_last");
|
||||
|
||||
statistic_increment(ha_read_last_count,&LOCK_status);
|
||||
int error=myrg_rlast(file, buf, active_index);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::rnd_init(bool scan)
|
||||
{
|
||||
return myrg_extra(file,HA_EXTRA_RESET,0);
|
||||
DBUG_ENTER("ha_myisammrg::rnd_init");
|
||||
|
||||
DBUG_RETURN(myrg_extra(file,HA_EXTRA_RESET,0));
|
||||
}
|
||||
|
||||
int ha_myisammrg::rnd_next(byte *buf)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::rnd_next");
|
||||
|
||||
statistic_increment(ha_read_rnd_next_count,&LOCK_status);
|
||||
int error=myrg_rrnd(file, buf, HA_OFFSET_ERROR);
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_myisammrg::rnd_pos(byte * buf, byte *pos)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::rnd_pos");
|
||||
|
||||
statistic_increment(ha_read_rnd_count,&LOCK_status);
|
||||
int error=myrg_rrnd(file, buf, ha_get_ptr(pos,ref_length));
|
||||
table->status=error ? STATUS_NOT_FOUND: 0;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
void ha_myisammrg::position(const byte *record)
|
||||
{
|
||||
ulonglong position= myrg_position(file);
|
||||
DBUG_ENTER("ha_myisammrg::position");
|
||||
|
||||
ha_store_ptr(ref, ref_length, (my_off_t) position);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
void ha_myisammrg::info(uint flag)
|
||||
{
|
||||
MYMERGE_INFO info;
|
||||
DBUG_ENTER("ha_myisammrg::info");
|
||||
|
||||
(void) myrg_status(file,&info,flag);
|
||||
/*
|
||||
The following fails if one has not compiled MySQL with -DBIG_TABLES
|
||||
@ -216,17 +251,20 @@ void ha_myisammrg::info(uint flag)
|
||||
#else
|
||||
ref_length=4; // Can't be > than my_off_t
|
||||
#endif
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
int ha_myisammrg::extra(enum ha_extra_function operation)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::extra");
|
||||
|
||||
/* As this is just a mapping, we don't have to force the underlying
|
||||
tables to be closed */
|
||||
if (operation == HA_EXTRA_FORCE_REOPEN ||
|
||||
operation == HA_EXTRA_PREPARE_FOR_DELETE)
|
||||
return 0;
|
||||
return myrg_extra(file,operation,0);
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(myrg_extra(file,operation,0));
|
||||
}
|
||||
|
||||
|
||||
@ -234,27 +272,35 @@ int ha_myisammrg::extra(enum ha_extra_function operation)
|
||||
|
||||
int ha_myisammrg::extra_opt(enum ha_extra_function operation, ulong cache_size)
|
||||
{
|
||||
DBUG_ENTER("ha_myisammrg::extra_opt");
|
||||
|
||||
if ((specialflag & SPECIAL_SAFE_MODE) &
|
||||
(operation == HA_EXTRA_WRITE_CACHE ||
|
||||
operation == HA_EXTRA_BULK_INSERT_BEGIN))
|
||||
return 0;
|
||||
return myrg_extra(file, operation, (void*) &cache_size);
|
||||
DBUG_RETURN(0);
|
||||
DBUG_RETURN(myrg_extra(file, operation, (void*) &cache_size));
|
||||
}
|
||||
|
||||
|
||||
int ha_myisammrg::reset(void)
|
||||
{
|
||||
return myrg_extra(file,HA_EXTRA_RESET,0);
|
||||
DBUG_ENTER("ha_myisammrg::reset");
|
||||
|
||||
DBUG_RETURN(myrg_extra(file,HA_EXTRA_RESET,0));
|
||||
}
|
||||
|
||||
int ha_myisammrg::external_lock(THD *thd, int lock_type)
|
||||
{
|
||||
return myrg_lock_database(file,lock_type);
|
||||
DBUG_ENTER("ha_myisammrg::external_lock");
|
||||
|
||||
DBUG_RETURN(myrg_lock_database(file,lock_type));
|
||||
}
|
||||
|
||||
uint ha_myisammrg::lock_count(void) const
|
||||
{
|
||||
return file->tables;
|
||||
DBUG_ENTER("ha_myisammrg::lock_count");
|
||||
|
||||
DBUG_RETURN(file->tables);
|
||||
}
|
||||
|
||||
|
||||
@ -263,6 +309,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
|
||||
enum thr_lock_type lock_type)
|
||||
{
|
||||
MYRG_TABLE *open_table;
|
||||
DBUG_ENTER("**ha_myisammrg::store_lock");
|
||||
|
||||
for (open_table=file->open_tables ;
|
||||
open_table != file->end_table ;
|
||||
@ -272,13 +319,14 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd,
|
||||
if (lock_type != TL_IGNORE && open_table->table->lock.type == TL_UNLOCK)
|
||||
open_table->table->lock.type=lock_type;
|
||||
}
|
||||
return to;
|
||||
DBUG_RETURN(to);
|
||||
}
|
||||
|
||||
void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info)
|
||||
{
|
||||
// [phi] auto_increment stuff is missing (but currently not needed)
|
||||
DBUG_ENTER("ha_myisammrg::update_create_info");
|
||||
|
||||
// [phi] auto_increment stuff is missing (but currently not needed)
|
||||
if (!(create_info->used_fields & HA_CREATE_USED_UNION))
|
||||
{
|
||||
MYRG_TABLE *open_table;
|
||||
@ -327,7 +375,28 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
|
||||
sizeof(char*))))
|
||||
DBUG_RETURN(1);
|
||||
for (pos=table_names ; tables ; tables=tables->next)
|
||||
*pos++= tables->real_name;
|
||||
{
|
||||
char *table_name;
|
||||
if (create_info->options & HA_LEX_CREATE_TMP_TABLE)
|
||||
{
|
||||
TABLE **tbl=find_temporary_table(current_thd,
|
||||
tables->db, tables->real_name);
|
||||
if (!tbl)
|
||||
{
|
||||
table_name=sql_alloc(1+
|
||||
my_snprintf(buff,FN_REFLEN,"%s/%s/%s",mysql_real_data_home,
|
||||
tables->db, tables->real_name));
|
||||
if (!table_name)
|
||||
DBUG_RETURN(1);
|
||||
strcpy(table_name, buff);
|
||||
}
|
||||
else
|
||||
table_name=(*tbl)->path;
|
||||
}
|
||||
else
|
||||
table_name=tables->real_name;
|
||||
*pos++= table_name;
|
||||
}
|
||||
*pos=0;
|
||||
DBUG_RETURN(myrg_create(fn_format(buff,name,"","",2+4+16),
|
||||
(const char **) table_names,
|
||||
@ -338,6 +407,8 @@ int ha_myisammrg::create(const char *name, register TABLE *form,
|
||||
void ha_myisammrg::append_create_info(String *packet)
|
||||
{
|
||||
char buff[FN_REFLEN];
|
||||
DBUG_ENTER("ha_myisammrg::append_create_info");
|
||||
|
||||
if (file->merge_insert_method != MERGE_INSERT_DISABLED)
|
||||
{
|
||||
packet->append(" INSERT_METHOD=",15);
|
||||
@ -357,4 +428,5 @@ void ha_myisammrg::append_create_info(String *packet)
|
||||
packet->append(buff,(uint) strlen(buff));
|
||||
}
|
||||
packet->append(')');
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
131
sql/handler.cc
131
sql/handler.cc
@ -72,14 +72,16 @@ TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
|
||||
|
||||
enum db_type ha_checktype(enum db_type database_type)
|
||||
{
|
||||
DBUG_ENTER("ha_checktype");
|
||||
|
||||
switch (database_type) {
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
case DB_TYPE_BERKELEY_DB:
|
||||
return(berkeley_skip ? DB_TYPE_MYISAM : database_type);
|
||||
DBUG_RETURN((berkeley_skip ? DB_TYPE_MYISAM : database_type));
|
||||
#endif
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
case DB_TYPE_INNODB:
|
||||
return(innodb_skip ? DB_TYPE_MYISAM : database_type);
|
||||
DBUG_RETURN((innodb_skip ? DB_TYPE_MYISAM : database_type));
|
||||
#endif
|
||||
#ifndef NO_HASH
|
||||
case DB_TYPE_HASH:
|
||||
@ -91,52 +93,57 @@ enum db_type ha_checktype(enum db_type database_type)
|
||||
case DB_TYPE_HEAP:
|
||||
case DB_TYPE_MYISAM:
|
||||
case DB_TYPE_MRG_MYISAM:
|
||||
return (database_type); /* Database exists on system */
|
||||
DBUG_RETURN((database_type)); /* Database exists on system */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return(DB_TYPE_MYISAM); /* Use this as default */
|
||||
DBUG_RETURN((DB_TYPE_MYISAM)); /* Use this as default */
|
||||
} /* ha_checktype */
|
||||
|
||||
|
||||
handler *get_new_handler(TABLE *table, enum db_type db_type)
|
||||
{
|
||||
DBUG_ENTER("*get_new_handler");
|
||||
|
||||
switch (db_type) {
|
||||
#ifndef NO_HASH
|
||||
return new ha_hash(table);
|
||||
DBUG_RETURN(new ha_hash(table));
|
||||
#endif
|
||||
#ifdef HAVE_ISAM
|
||||
case DB_TYPE_MRG_ISAM:
|
||||
return new ha_isammrg(table);
|
||||
DBUG_RETURN(new ha_isammrg(table));
|
||||
case DB_TYPE_ISAM:
|
||||
return new ha_isam(table);
|
||||
DBUG_RETURN(new ha_isam(table));
|
||||
#endif
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
case DB_TYPE_BERKELEY_DB:
|
||||
return new ha_berkeley(table);
|
||||
DBUG_RETURN(new ha_berkeley(table));
|
||||
#endif
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
case DB_TYPE_INNODB:
|
||||
return new ha_innobase(table);
|
||||
DBUG_RETURN(new ha_innobase(table));
|
||||
#endif
|
||||
case DB_TYPE_HEAP:
|
||||
return new ha_heap(table);
|
||||
DBUG_RETURN(new ha_heap(table));
|
||||
case DB_TYPE_MYISAM:
|
||||
default: // should never happen
|
||||
return new ha_myisam(table);
|
||||
DBUG_RETURN(new ha_myisam(table));
|
||||
case DB_TYPE_MRG_MYISAM:
|
||||
return new ha_myisammrg(table);
|
||||
DBUG_RETURN(new ha_myisammrg(table));
|
||||
}
|
||||
DBUG_RETURN(NULL); // impossible
|
||||
}
|
||||
|
||||
int ha_init()
|
||||
{
|
||||
DBUG_ENTER("ha_init");
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
if (!berkeley_skip)
|
||||
{
|
||||
int error;
|
||||
if ((error=berkeley_init()))
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
if (!berkeley_skip) // If we couldn't use handler
|
||||
opt_using_transactions=1;
|
||||
else
|
||||
@ -147,14 +154,14 @@ int ha_init()
|
||||
if (!innodb_skip)
|
||||
{
|
||||
if (innobase_init())
|
||||
return -1;
|
||||
DBUG_RETURN(-1);
|
||||
if (!innodb_skip) // If we couldn't use handler
|
||||
opt_using_transactions=1;
|
||||
else
|
||||
have_innodb=SHOW_OPTION_DISABLED;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
DBUG_RETURN(0);
|
||||
}
|
||||
|
||||
/* close, flush or restart databases */
|
||||
@ -163,6 +170,8 @@ int ha_init()
|
||||
int ha_panic(enum ha_panic_function flag)
|
||||
{
|
||||
int error=0;
|
||||
DBUG_ENTER("ha_panic");
|
||||
|
||||
#ifndef NO_HASH
|
||||
error|=h_panic(flag); /* fix hash */
|
||||
#endif
|
||||
@ -181,23 +190,29 @@ int ha_panic(enum ha_panic_function flag)
|
||||
if (!innodb_skip)
|
||||
error|=innobase_end();
|
||||
#endif
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
} /* ha_panic */
|
||||
|
||||
void ha_drop_database(char* path)
|
||||
{
|
||||
DBUG_ENTER("ha_drop_database");
|
||||
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
if (!innodb_skip)
|
||||
innobase_drop_database(path);
|
||||
#endif
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
void ha_close_connection(THD* thd)
|
||||
{
|
||||
DBUG_ENTER("ha_close_connection");
|
||||
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
if (!innodb_skip)
|
||||
innobase_close_connection(thd);
|
||||
#endif
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -247,6 +262,8 @@ int ha_report_binlog_offset_and_commit(THD *thd,
|
||||
my_off_t end_offset)
|
||||
{
|
||||
int error= 0;
|
||||
DBUG_ENTER("ha_report_binlog_offset_and_commit");
|
||||
|
||||
#ifdef HAVE_INNOBASE_DB
|
||||
THD_TRANS *trans;
|
||||
trans = &thd->transaction.all;
|
||||
@ -263,7 +280,7 @@ int ha_report_binlog_offset_and_commit(THD *thd,
|
||||
trans->innodb_active_trans=0;
|
||||
}
|
||||
#endif
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int ha_commit_trans(THD *thd, THD_TRANS* trans)
|
||||
@ -381,6 +398,8 @@ int ha_rollback_trans(THD *thd, THD_TRANS *trans)
|
||||
bool ha_flush_logs()
|
||||
{
|
||||
bool result=0;
|
||||
DBUG_ENTER("ha_flush_logs");
|
||||
|
||||
#ifdef HAVE_BERKELEY_DB
|
||||
if (!berkeley_skip && berkeley_flush_logs())
|
||||
result=1;
|
||||
@ -389,7 +408,7 @@ bool ha_flush_logs()
|
||||
if (!innodb_skip && innobase_flush_logs())
|
||||
result=1;
|
||||
#endif
|
||||
return result;
|
||||
DBUG_RETURN(result);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -400,15 +419,19 @@ bool ha_flush_logs()
|
||||
int ha_delete_table(enum db_type table_type, const char *path)
|
||||
{
|
||||
handler *file=get_new_handler((TABLE*) 0, table_type);
|
||||
DBUG_ENTER("ha_delete_table");
|
||||
|
||||
if (!file)
|
||||
return ENOENT;
|
||||
DBUG_RETURN(ENOENT);
|
||||
int error=file->delete_table(path);
|
||||
delete file;
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
void ha_store_ptr(byte *buff, uint pack_length, my_off_t pos)
|
||||
{
|
||||
DBUG_ENTER("ha_store_ptr");
|
||||
|
||||
switch (pack_length) {
|
||||
#if SIZEOF_OFF_T > 4
|
||||
case 8: mi_int8store(buff,pos); break;
|
||||
@ -421,12 +444,14 @@ void ha_store_ptr(byte *buff, uint pack_length, my_off_t pos)
|
||||
case 2: mi_int2store(buff,(uint) pos); break;
|
||||
case 1: buff[0]= (uchar) pos; break;
|
||||
}
|
||||
return;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
my_off_t ha_get_ptr(byte *ptr, uint pack_length)
|
||||
{
|
||||
my_off_t pos;
|
||||
DBUG_ENTER("ha_get_ptr");
|
||||
|
||||
switch (pack_length) {
|
||||
#if SIZEOF_OFF_T > 4
|
||||
case 8:
|
||||
@ -458,7 +483,7 @@ my_off_t ha_get_ptr(byte *ptr, uint pack_length)
|
||||
pos=0; // Impossible
|
||||
break;
|
||||
}
|
||||
return pos;
|
||||
DBUG_RETURN(pos);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -512,32 +537,44 @@ int handler::ha_open(const char *name, int mode, int test_if_locked)
|
||||
|
||||
int handler::check(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
return HA_ADMIN_NOT_IMPLEMENTED;
|
||||
DBUG_ENTER("handler::check");
|
||||
|
||||
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int handler::backup(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
return HA_ADMIN_NOT_IMPLEMENTED;
|
||||
DBUG_ENTER("handler::backup");
|
||||
|
||||
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int handler::restore(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
return HA_ADMIN_NOT_IMPLEMENTED;
|
||||
DBUG_ENTER("handler::restore");
|
||||
|
||||
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int handler::repair(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
return HA_ADMIN_NOT_IMPLEMENTED;
|
||||
DBUG_ENTER("handler::repair");
|
||||
|
||||
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int handler::optimize(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
return HA_ADMIN_NOT_IMPLEMENTED;
|
||||
DBUG_ENTER("handler::optimize");
|
||||
|
||||
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
int handler::analyze(THD* thd, HA_CHECK_OPT* check_opt)
|
||||
{
|
||||
return HA_ADMIN_NOT_IMPLEMENTED;
|
||||
DBUG_ENTER("handler::analyze");
|
||||
|
||||
DBUG_RETURN(HA_ADMIN_NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -582,7 +619,9 @@ int handler::read_first_row(byte * buf, uint primary_key)
|
||||
|
||||
int handler::restart_rnd_next(byte *buf, byte *pos)
|
||||
{
|
||||
return HA_ERR_WRONG_COMMAND;
|
||||
DBUG_ENTER("handler::restart_rnd_next");
|
||||
|
||||
DBUG_RETURN(HA_ERR_WRONG_COMMAND);
|
||||
}
|
||||
|
||||
|
||||
@ -591,6 +630,8 @@ int handler::restart_rnd_next(byte *buf, byte *pos)
|
||||
void handler::update_timestamp(byte *record)
|
||||
{
|
||||
long skr= (long) current_thd->query_start();
|
||||
DBUG_ENTER("handler::update_timestamp");
|
||||
|
||||
#ifdef WORDS_BIGENDIAN
|
||||
if (table->db_low_byte_first)
|
||||
{
|
||||
@ -599,7 +640,7 @@ void handler::update_timestamp(byte *record)
|
||||
else
|
||||
#endif
|
||||
longstore(record,skr);
|
||||
return;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -633,6 +674,7 @@ longlong handler::get_auto_increment()
|
||||
{
|
||||
longlong nr;
|
||||
int error;
|
||||
DBUG_ENTER("handler::get_auto_increment");
|
||||
|
||||
(void) extra(HA_EXTRA_KEYREAD);
|
||||
index_init(table->next_number_index);
|
||||
@ -656,7 +698,7 @@ longlong handler::get_auto_increment()
|
||||
val_int_offset(table->rec_buff_length)+1;
|
||||
index_end();
|
||||
(void) extra(HA_EXTRA_NO_KEYREAD);
|
||||
return nr;
|
||||
DBUG_RETURN(nr);
|
||||
}
|
||||
|
||||
/* Print error that we got from handler function */
|
||||
@ -778,6 +820,8 @@ uint handler::get_dup_key(int error)
|
||||
int handler::delete_table(const char *name)
|
||||
{
|
||||
int error=0;
|
||||
DBUG_ENTER("handler::delete_table");
|
||||
|
||||
for (const char **ext=bas_ext(); *ext ; ext++)
|
||||
{
|
||||
if (delete_file(name,*ext,2))
|
||||
@ -786,7 +830,7 @@ int handler::delete_table(const char *name)
|
||||
break;
|
||||
}
|
||||
}
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
@ -807,14 +851,16 @@ int handler::rename_table(const char * from, const char * to)
|
||||
int ha_recovery_logging(THD *thd, bool on)
|
||||
{
|
||||
int error=0;
|
||||
|
||||
DBUG_ENTER("ha_recovery_logging");
|
||||
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
int handler::index_next_same(byte *buf, const byte *key, uint keylen)
|
||||
{
|
||||
int error;
|
||||
DBUG_ENTER("handler::index_next_same");
|
||||
|
||||
if (!(error=index_next(buf)))
|
||||
{
|
||||
if (key_cmp(table, key, active_index, keylen))
|
||||
@ -823,7 +869,7 @@ int handler::index_next_same(byte *buf, const byte *key, uint keylen)
|
||||
error=HA_ERR_END_OF_FILE;
|
||||
}
|
||||
}
|
||||
return error;
|
||||
DBUG_RETURN(error);
|
||||
}
|
||||
|
||||
|
||||
@ -836,7 +882,9 @@ int handler::index_next_same(byte *buf, const byte *key, uint keylen)
|
||||
|
||||
int handler::delete_all_rows()
|
||||
{
|
||||
return (my_errno=HA_ERR_WRONG_COMMAND);
|
||||
DBUG_ENTER("handler::delete_all_rows");
|
||||
|
||||
DBUG_RETURN((my_errno=HA_ERR_WRONG_COMMAND));
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -882,26 +930,37 @@ int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
|
||||
|
||||
void ha_key_cache(void)
|
||||
{
|
||||
DBUG_ENTER("ha_key_cache");
|
||||
|
||||
if (keybuff_size)
|
||||
(void) init_key_cache(keybuff_size);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
void ha_resize_key_cache(void)
|
||||
{
|
||||
DBUG_ENTER("ha_resize_key_cache");
|
||||
|
||||
(void) resize_key_cache(keybuff_size);
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
||||
|
||||
static int NEAR_F delete_file(const char *name,const char *ext,int extflag)
|
||||
{
|
||||
char buff[FN_REFLEN];
|
||||
DBUG_ENTER("delete_file");
|
||||
|
||||
VOID(fn_format(buff,name,"",ext,extflag | 4));
|
||||
return(my_delete_with_symlink(buff,MYF(MY_WME)));
|
||||
DBUG_RETURN((my_delete_with_symlink(buff,MYF(MY_WME))));
|
||||
}
|
||||
|
||||
void st_ha_check_opt::init()
|
||||
{
|
||||
DBUG_ENTER("st_ha_check_opt::init");
|
||||
|
||||
flags= sql_flags= 0;
|
||||
sort_buffer_size = current_thd->variables.myisam_sort_buff_size;
|
||||
DBUG_VOID_RETURN;
|
||||
}
|
||||
|
@ -350,13 +350,19 @@ void Item_func_between::fix_length_and_dec()
|
||||
*/
|
||||
if (!args[0] || !args[1] || !args[2])
|
||||
return;
|
||||
cmp_type=args[0]->result_type();
|
||||
if (args[0]->binary)
|
||||
cmp_type=item_cmp_type(args[0]->result_type(),
|
||||
item_cmp_type(args[1]->result_type(),
|
||||
args[2]->result_type()));
|
||||
if (args[0]->binary | args[1]->binary | args[2]->binary)
|
||||
string_compare=stringcmp;
|
||||
else
|
||||
string_compare=sortcmp;
|
||||
|
||||
// Make a special case of compare with fields to get nicer DATE comparisons
|
||||
/*
|
||||
Make a special case of compare with date/time and longlong fields.
|
||||
They are compared as integers, so for const item this time-consuming
|
||||
conversion can be done only once, not for every single comparison
|
||||
*/
|
||||
if (args[0]->type() == FIELD_ITEM)
|
||||
{
|
||||
Field *field=((Item_field*) args[0])->field;
|
||||
|
@ -1404,7 +1404,11 @@ information that should help you find out what is causing the crash.\n");
|
||||
#endif /* HAVE_STACKTRACE */
|
||||
|
||||
if (test_flags & TEST_CORE_ON_SIGNAL)
|
||||
{
|
||||
fprintf(stderr, "Writing a core file\n");
|
||||
fflush(stderr);
|
||||
write_core(sig);
|
||||
}
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
350
sql/opt_range.cc
350
sql/opt_range.cc
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -206,7 +206,7 @@ resolve it\n");
|
||||
|
||||
/* Produce a core for the thread */
|
||||
|
||||
#ifdef HAVE_LINUXTHREADS
|
||||
#ifdef NOT_USED /* HAVE_LINUXTHREADS */
|
||||
void write_core(int sig)
|
||||
{
|
||||
signal(sig, SIG_DFL);
|
||||
|
Reference in New Issue
Block a user