Commit c235691d authored by Vicențiu Ciorbaru's avatar Vicențiu Ciorbaru

Merge branch '10.4' into 10.5

parents a786f50d 6a634576
File mode changed from 100644 to 100755
...@@ -5,9 +5,10 @@ insert t2 values (5,6),(7,8); ...@@ -5,9 +5,10 @@ insert t2 values (5,6),(7,8);
create table t0 (x int); create table t0 (x int);
insert t0 values (11), (22); insert t0 values (11), (22);
create trigger tr1 before update on t1 for each row insert t0 values (new.b); create trigger tr1 before update on t1 for each row insert t0 values (new.b);
set debug_sync='open_tables_after_open_and_process_table WAIT_FOR cont'; set debug_sync='open_tables_after_open_and_process_table SIGNAL ready WAIT_FOR cont';
update t1 join t2 on (a=c+4) set b=d; update t1 join t2 on (a=c+4) set b=d;
connect con1, localhost, root; connect con1, localhost, root;
set debug_sync='now WAIT_FOR ready';
set debug_sync='mdl_acquire_lock_wait SIGNAL cont'; set debug_sync='mdl_acquire_lock_wait SIGNAL cont';
lock table t1 write, t0 write; lock table t1 write, t0 write;
disconnect con1; disconnect con1;
......
...@@ -10,12 +10,11 @@ create table t0 (x int); ...@@ -10,12 +10,11 @@ create table t0 (x int);
insert t0 values (11), (22); insert t0 values (11), (22);
create trigger tr1 before update on t1 for each row insert t0 values (new.b); create trigger tr1 before update on t1 for each row insert t0 values (new.b);
set debug_sync='open_tables_after_open_and_process_table WAIT_FOR cont'; set debug_sync='open_tables_after_open_and_process_table SIGNAL ready WAIT_FOR cont';
send update t1 join t2 on (a=c+4) set b=d; send update t1 join t2 on (a=c+4) set b=d;
connect con1, localhost, root; connect con1, localhost, root;
let $wait_condition= select count(*) from information_schema.processlist where state = ' debug sync point: open_tables_after_open_and_process_table' set debug_sync='now WAIT_FOR ready';
source include/wait_condition.inc;
set debug_sync='mdl_acquire_lock_wait SIGNAL cont'; set debug_sync='mdl_acquire_lock_wait SIGNAL cont';
lock table t1 write, t0 write; lock table t1 write, t0 write;
let $wait_condition= select count(*) from information_schema.processlist where state = 'Waiting for table metadata lock' let $wait_condition= select count(*) from information_schema.processlist where state = 'Waiting for table metadata lock'
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#endif #endif
#include "maria_def.h" #include "maria_def.h"
#include "trnman_public.h"
#include "trnman.h"
#include <queues.h> #include <queues.h>
#include <my_tree.h> #include <my_tree.h>
#include "mysys_err.h" #include "mysys_err.h"
...@@ -30,13 +32,16 @@ ...@@ -30,13 +32,16 @@
#define __GNU_LIBRARY__ /* Skip warnings in getopt.h */ #define __GNU_LIBRARY__ /* Skip warnings in getopt.h */
#endif #endif
#include <my_getopt.h> #include <my_getopt.h>
#include <assert.h> #include <my_handler_errors.h>
#if SIZEOF_LONG_LONG > 4 #if SIZEOF_LONG_LONG > 4
#define BITS_SAVED 64 #define BITS_SAVED 64
#else #else
#define BITS_SAVED 32 #define BITS_SAVED 32
#endif #endif
#ifndef MAX_INTERNAL_TRID
#define MAX_INTERNAL_TRID 0xffffffffffffLL
#endif
#define IS_OFFSET ((uint) 32768) /* Bit if offset or char in tree */ #define IS_OFFSET ((uint) 32768) /* Bit if offset or char in tree */
#define HEAD_LENGTH 32 #define HEAD_LENGTH 32
...@@ -178,11 +183,6 @@ static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count); ...@@ -178,11 +183,6 @@ static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count);
static int fakecmp(my_off_t **count1, my_off_t **count2); static int fakecmp(my_off_t **count1, my_off_t **count2);
#endif #endif
static int error_on_write=0,test_only=0,verbose=0,silent=0,
write_loop=0,force_pack=0, isamchk_neaded=0;
static int tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
static my_bool backup, opt_wait;
/* /*
tree_buff_length is somewhat arbitrary. The bigger it is the better tree_buff_length is somewhat arbitrary. The bigger it is the better
the chance to win in terms of compression factor. On the other hand, the chance to win in terms of compression factor. On the other hand,
...@@ -190,6 +190,12 @@ static my_bool backup, opt_wait; ...@@ -190,6 +190,12 @@ static my_bool backup, opt_wait;
is coded with 16 bits in the header. Hence the limit is 2**16 - 1. is coded with 16 bits in the header. Hence the limit is 2**16 - 1.
*/ */
static uint tree_buff_length= 65536 - MALLOC_OVERHEAD; static uint tree_buff_length= 65536 - MALLOC_OVERHEAD;
static int error_on_write=0,test_only=0,verbose=0,silent=0,
write_loop=0,force_pack=0, isamchk_neaded=0;
static int tmpfile_createflag=O_RDWR | O_TRUNC | O_EXCL;
static my_bool backup, opt_wait;
static my_bool opt_ignore_control_file, opt_require_control_file;
static char tmp_dir[FN_REFLEN]={0},*join_table; static char tmp_dir[FN_REFLEN]={0},*join_table;
static my_off_t intervall_length; static my_off_t intervall_length;
static ha_checksum glob_crc; static ha_checksum glob_crc;
...@@ -199,19 +205,52 @@ static HUFF_COUNTS *global_count; ...@@ -199,19 +205,52 @@ static HUFF_COUNTS *global_count;
static char zero_string[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; static char zero_string[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
static const char *load_default_groups[]= { "ariapack",0 }; static const char *load_default_groups[]= { "ariapack",0 };
/* The main program */ /*
Register handler error messages for usage with my_error()
NOTES
This is safe to call multiple times as my_error_register()
will ignore calls to register already registered error numbers.
*/
static const char **get_handler_error_messages(int e __attribute__((unused)))
{
return handler_error_messages;
}
/* The main program */
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
int error,ok; int error,ok;
PACK_MRG_INFO merge; PACK_MRG_INFO merge;
char **default_argv; char **default_argv;
my_bool no_control_file= 0;
MY_INIT(argv[0]); MY_INIT(argv[0]);
maria_data_root= (char *)".";
load_defaults_or_exit("my", load_default_groups, &argc, &argv); load_defaults_or_exit("my", load_default_groups, &argc, &argv);
default_argv= argv; default_argv= argv;
get_options(&argc,&argv); get_options(&argc,&argv);
my_error_register(get_handler_error_messages, HA_ERR_FIRST,
HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
if (!opt_ignore_control_file &&
(no_control_file= ma_control_file_open(FALSE,
(opt_require_control_file ||
!silent))) &&
opt_require_control_file)
{
error= 1;
goto end;
}
maria_init(); maria_init();
if (no_control_file || force_pack)
{
/* Assume that all rows exists */
trnman_init(MAX_INTERNAL_TRID-16);
}
error=ok=isamchk_neaded=0; error=ok=isamchk_neaded=0;
if (join_table) if (join_table)
...@@ -239,9 +278,13 @@ int main(int argc, char **argv) ...@@ -239,9 +278,13 @@ int main(int argc, char **argv)
} }
if (ok && isamchk_neaded && !silent) if (ok && isamchk_neaded && !silent)
puts("Remember to run aria_chk -rq on compressed tables"); puts("Remember to run aria_chk -rq on compressed tables");
end:
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
free_defaults(default_argv); free_defaults(default_argv);
my_error_unregister(HA_ERR_FIRST,
HA_ERR_FIRST+ array_elements(handler_error_messages)-1);
maria_end(); maria_end();
my_end(verbose ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR); my_end(verbose ? MY_CHECK_ERROR | MY_GIVE_INFO : MY_CHECK_ERROR);
exit(error ? 2 : 0); exit(error ? 2 : 0);
...@@ -263,17 +306,29 @@ static struct my_option my_long_options[] = ...@@ -263,17 +306,29 @@ static struct my_option my_long_options[] =
{"character-sets-dir", OPT_CHARSETS_DIR_MP, {"character-sets-dir", OPT_CHARSETS_DIR_MP,
"Directory where character sets are.", (char**) &charsets_dir, "Directory where character sets are.", (char**) &charsets_dir,
(char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, (char**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"datadir", 'h',
"Path for control file (and logs if --logdir not used).",
&maria_data_root, 0, 0, GET_STR, REQUIRED_ARG,
0, 0, 0, 0, 0, 0},
{"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.",
0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"force", 'f', {"force", 'f',
"Force packing of table even if it gets bigger or if tempfile exists.", "Force packing of table even if it gets bigger or if tempfile exists.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "ignore-control-file", 0,
"Ignore the control file",
(uchar**)&opt_ignore_control_file, 0, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{"join", 'j', {"join", 'j',
"Join all given tables into 'new_table_name'. All tables MUST have identical layouts.", "Join all given tables into 'new_table_name'. All tables MUST have identical layouts.",
&join_table, &join_table, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, &join_table, &join_table, 0, GET_STR, REQUIRED_ARG, 0, 0, 0,
0, 0, 0}, 0, 0, 0},
{"help", '?', "Display this help and exit.", {"help", '?', "Display this help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{ "require-control-file", 0,
"Abort if cannot find control file",
(uchar**)&opt_require_control_file, 0, 0, GET_BOOL, NO_ARG,
0, 0, 0, 0, 0, 0},
{"silent", 's', "Be more silent.", {"silent", 's', "Be more silent.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"tmpdir", 'T', "Use temporary directory to store temporary table.", {"tmpdir", 'T', "Use temporary directory to store temporary table.",
...@@ -396,6 +451,47 @@ static void get_options(int *argc,char ***argv) ...@@ -396,6 +451,47 @@ static void get_options(int *argc,char ***argv)
} }
static void print_error(int error, const char *filename)
{
switch (error) {
case HA_ERR_CRASHED:
fprintf(stderr, "'%s' doesn't have a correct index definition. You need to recreate it before you can do a repair",filename);
break;
case HA_ERR_NOT_A_TABLE:
fprintf(stderr, "'%s' is not a Aria table",filename);
break;
case HA_ERR_CRASHED_ON_USAGE:
fprintf(stderr, "'%s' is marked as crashed",filename);
break;
case HA_ERR_CRASHED_ON_REPAIR:
fprintf(stderr, "'%s' is marked as crashed after last repair",filename);
break;
case HA_ERR_OLD_FILE:
fprintf(stderr, "'%s' has transactions newer than registered in control file. If this is ok, please re-run with --ignore-control-file", filename);
break;
case HA_ERR_NEW_FILE:
fprintf(stderr, "'%s' uses new features not supported by this version of the Aria library", filename);
break;
case HA_ERR_END_OF_FILE:
fprintf(stderr, "Couldn't read complete header from '%s'", filename);
break;
case EAGAIN:
fprintf(stderr, "'%s' is locked. Use -w to wait until unlocked",filename);
break;
case ENOENT:
fprintf(stderr, "File '%s' doesn't exist",filename);
break;
case EACCES:
fprintf(stderr, "You don't have permission to use '%s'", filename);
break;
default:
fprintf(stderr, "%d when opening Aria table '%s'", error, filename);
break;
}
fputc('\n',stderr);
}
static MARIA_HA *open_maria_file(char *name,int mode) static MARIA_HA *open_maria_file(char *name,int mode)
{ {
MARIA_HA *isam_file; MARIA_HA *isam_file;
...@@ -403,10 +499,10 @@ static MARIA_HA *open_maria_file(char *name,int mode) ...@@ -403,10 +499,10 @@ static MARIA_HA *open_maria_file(char *name,int mode)
DBUG_ENTER("open_maria_file"); DBUG_ENTER("open_maria_file");
if (!(isam_file=maria_open(name, mode, HA_OPEN_IGNORE_MOVED_STATE | if (!(isam_file=maria_open(name, mode, HA_OPEN_IGNORE_MOVED_STATE |
(opt_wait ? HA_OPEN_WAIT_IF_LOCKED : (opt_wait ? HA_OPEN_WAIT_IF_LOCKED :
HA_OPEN_ABORT_IF_LOCKED), 0))) HA_OPEN_ABORT_IF_LOCKED), 0)))
{ {
fprintf(stderr, "%s gave error %d on open\n", name, my_errno); print_error(my_errno, name);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
share=isam_file->s; share=isam_file->s;
......
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