Commit d7c943b3 authored by Monty's avatar Monty

Some changes to prepare for updated maria-backup

- Updated prototype for is_binary_frm_header().
- Added extra argument to ma_control_file_open().
- Added ma_control_file_open_or_create() for usage by tests.
  (to make test a bit simpler).
parent 7246054c
......@@ -217,7 +217,7 @@ LEX_CUSTRING build_frm_image(THD *thd, const LEX_CSTRING &table,
#define FRM_FORMINFO_SIZE 288
#define FRM_MAX_SIZE (1024*1024)
static inline bool is_binary_frm_header(uchar *head)
static inline bool is_binary_frm_header(const uchar *head)
{
return head[0] == 254
&& head[1] == 1
......
......@@ -28,6 +28,9 @@ MDEV-11782: Rewritten for MariaDB 10.2 by Marko Mäkelä, MariaDB Corporation.
#include "log0log.h"
/** innodb_encrypt_log: whether to encrypt the redo log */
extern my_bool srv_encrypt_log;
/** Initialize the redo log encryption key and random parameters
when creating a new redo log.
The random parameters will be persisted in the log header.
......
......@@ -145,7 +145,8 @@ int main(int argc, char **argv)
{
if ((ma_control_file_open(FALSE, opt_require_control_file ||
!(check_param.testflag & T_SILENT),
TRUE)))
TRUE,
control_file_open_flags)))
{
if (opt_require_control_file ||
(opt_transaction_logging && (check_param.testflag & T_REP_ANY)))
......
......@@ -239,7 +239,8 @@ int main(int argc, char **argv)
if (!opt_ignore_control_file &&
(no_control_file= ma_control_file_open(FALSE,
(opt_require_control_file ||
!silent), FALSE)) &&
!silent), FALSE,
control_file_open_flags)) &&
opt_require_control_file)
{
error= 1;
......
......@@ -104,7 +104,7 @@ int main(int argc, char **argv)
goto end;
}
/* we don't want to create a control file, it MUST exist */
if (ma_control_file_open(FALSE, TRUE, TRUE))
if (ma_control_file_open(FALSE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't open control file (%d)\n", errno);
goto err;
......
......@@ -38,6 +38,7 @@ C_MODE_START
#include "ma_recovery.h"
C_MODE_END
#include "ma_trnman.h"
#include "ma_loghandler.h"
//#include "sql_priv.h"
#include "protocol.h"
......@@ -3876,7 +3877,8 @@ static int ha_maria_init(void *p)
if (!aria_readonly)
res= maria_upgrade();
res= res || maria_init();
tmp= ma_control_file_open(!aria_readonly, !aria_readonly, !aria_readonly);
tmp= ma_control_file_open(!aria_readonly, !aria_readonly, !aria_readonly,
control_file_open_flags);
res= res || aria_readonly ? tmp == CONTROL_FILE_LOCKED : tmp != 0;
res= res ||
((force_start_after_recovery_failures != 0 && !aria_readonly) &&
......
......@@ -272,7 +272,8 @@ static int lock_control_file(const char *name, my_bool do_retry)
CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
my_bool print_error,
my_bool wait_for_lock)
my_bool wait_for_lock,
int open_flags)
{
uchar buffer[CF_MAX_SIZE];
char name[FN_REFLEN], errmsg_buff[256];
......@@ -280,7 +281,6 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
" file is probably in use by another process";
uint new_cf_create_time_size, new_cf_changeable_size, new_block_size;
my_off_t file_size;
int open_flags= O_BINARY | /*O_DIRECT |*/ O_RDWR | O_CLOEXEC;
int error= CONTROL_FILE_UNKNOWN_ERROR;
DBUG_ENTER("ma_control_file_open");
......@@ -460,6 +460,15 @@ CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
DBUG_RETURN(error);
}
/*
The most common way to open the control file when writing tests
*/
CONTROL_FILE_ERROR ma_control_file_open_or_create()
{
return ma_control_file_open(TRUE, TRUE, TRUE,
control_file_open_flags);
}
/*
Write information durably to the control file; stores this information into
......@@ -630,7 +639,7 @@ my_bool print_aria_log_control()
int error= CONTROL_FILE_UNKNOWN_ERROR;
uint recovery_fails;
File file;
DBUG_ENTER("ma_control_file_open");
DBUG_ENTER("print_aria_log_control");
if (fn_format(name, CONTROL_FILE_BASE_NAME,
maria_data_root, "", MYF(MY_WME)) == NullS)
......
......@@ -68,10 +68,13 @@ typedef enum enum_control_file_error {
CONTROL_FILE_ERROR ma_control_file_open(my_bool create_if_missing,
my_bool print_error,
my_bool wait_for_lock);
my_bool wait_for_lock,
int open_flags);
int ma_control_file_write_and_force(LSN last_checkpoint_lsn_arg,
uint32 last_logno_arg, TrID max_trid_arg,
uint8 recovery_failures_arg);
/* For simple programs that creates Aria files*/
CONTROL_FILE_ERROR ma_control_file_open_or_create();
int ma_control_file_end(void);
my_bool ma_control_file_inited(void);
my_bool print_aria_log_control(void);
......
......@@ -1099,10 +1099,6 @@ static TRANSLOG_FILE *get_current_logfile()
uchar maria_trans_file_magic[]=
{ (uchar) 254, (uchar) 254, (uchar) 11, '\001', 'M', 'A', 'R', 'I', 'A',
'L', 'O', 'G' };
#define LOG_HEADER_DATA_SIZE (sizeof(maria_trans_file_magic) + \
8 + 4 + 4 + 4 + 2 + 3 + \
LSN_STORE_SIZE)
/*
Write log file page header in the just opened new log file
......
......@@ -534,5 +534,13 @@ typedef enum
} enum_maria_sync_log_dir;
extern ulong sync_log_dir;
/* sizeof(maria_trans_file_magic) */
#define LOG_MAGIC_SIZE 12
#define LOG_HEADER_DATA_SIZE (LOG_MAGIC_SIZE + \
8 + 4 + 4 + 4 + 2 + 3 + \
LSN_STORE_SIZE)
/* Flags when creating aria_log_control */
#define control_file_open_flags (O_BINARY | /*O_DIRECT |*/ O_RDWR | O_CLOEXEC)
C_MODE_END
#endif
......@@ -101,7 +101,7 @@ int main(int argc, char *argv[])
if (maria_init() ||
(init_pagecache(maria_pagecache, maria_block_size * 16, 0, 0,
maria_block_size, 0, MY_WME) == 0) ||
ma_control_file_open(TRUE, TRUE, TRUE) ||
ma_control_file_open_or_create() ||
(init_pagecache(maria_log_pagecache,
TRANSLOG_PAGECACHE_SIZE, 0, 0,
TRANSLOG_PAGE_SIZE, 0, MY_WME) == 0) ||
......
......@@ -81,7 +81,7 @@ int main(int argc,char *argv[])
if (maria_init() ||
(init_pagecache(maria_pagecache, maria_block_size * 16, 0, 0,
maria_block_size, 0, MY_WME) == 0) ||
ma_control_file_open(TRUE, TRUE, TRUE) ||
ma_control_file_open_or_create() ||
(init_pagecache(maria_log_pagecache,
TRANSLOG_PAGECACHE_SIZE, 0, 0,
TRANSLOG_PAGE_SIZE, 0, MY_WME) == 0) ||
......
......@@ -90,7 +90,7 @@ int main(int argc, char *argv[])
if (maria_init() ||
(init_pagecache(maria_pagecache, pagecache_size, 0, 0,
maria_block_size, 0, MY_WME) == 0) ||
ma_control_file_open(TRUE, TRUE, TRUE) ||
ma_control_file_open_or_create() ||
(init_pagecache(maria_log_pagecache,
TRANSLOG_PAGECACHE_SIZE, 0, 0,
TRANSLOG_PAGE_SIZE, 0, MY_WME) == 0) ||
......
......@@ -47,7 +47,7 @@ int main(int argc __attribute__((unused)), char *argv[])
if (maria_init() ||
(init_pagecache(maria_pagecache, maria_block_size * 2000, 0, 0,
maria_block_size, 0, MY_WME) == 0) ||
ma_control_file_open(TRUE, TRUE, TRUE) ||
ma_control_file_open_or_create() ||
(init_pagecache(maria_log_pagecache,
TRANSLOG_PAGECACHE_SIZE, 0, 0,
TRANSLOG_PAGE_SIZE, 0, MY_WME) == 0) ||
......
......@@ -114,7 +114,7 @@ static CONTROL_FILE_ERROR local_ma_control_file_open(void)
{
CONTROL_FILE_ERROR error;
error_handler_hook= my_ignore_message;
error= ma_control_file_open(TRUE, TRUE, TRUE);
error= ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags);
error_handler_hook= default_error_handler_hook;
return error;
}
......
......@@ -197,7 +197,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -66,7 +66,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
if (ma_control_file_open(TRUE, TRUE,TRUE))
if (ma_control_file_open(TRUE, TRUE,TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -64,7 +64,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -280,7 +280,7 @@ int main(int argc __attribute__((unused)), char *argv[])
bzero(long_tr_id, 6);
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......@@ -443,7 +443,7 @@ int main(int argc __attribute__((unused)), char *argv[])
end_pagecache(&pagecache, 1);
ma_control_file_end();
if (ma_control_file_open(TRUE,TRUE,TRUE))
if (ma_control_file_open(TRUE,TRUE,TRUE, control_file_open_flags))
{
fprintf(stderr, "pass2: Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -331,7 +331,7 @@ int main(int argc __attribute__((unused)),
exit(1);
}
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -65,7 +65,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -66,7 +66,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......@@ -139,7 +139,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
}
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -69,7 +69,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
......@@ -67,7 +67,7 @@ int main(int argc __attribute__((unused)), char *argv[])
}
#endif
if (ma_control_file_open(TRUE, TRUE, TRUE))
if (ma_control_file_open(TRUE, TRUE, TRUE, control_file_open_flags))
{
fprintf(stderr, "Can't init control file (%d)\n", errno);
exit(1);
......
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