mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 23:34:34 +01:00
c719e1fd33
Automaticly disable ma_test_recovery if not compiled with debugging. This fixes that make test works in Maria. Fixed wrong merge of ma_init.c from 5.1 Portability fixes: - Use my_chmod() instead of my_chmod() - Use my_access() instead of my_stat() to test if file exists - Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable - No reason to test if file exists before we delete it include/my_sys.h: Added my_chmod include/mysys_err.h: Added error for my_chmod mysys/Makefile.am: Added my_chmod mysys/errors.c: Added error for my_chmod mysys/my_init.c: Syncronize with 5.1 to fix setting of QueryPerformanceFrequency() storage/maria/ma_test1.c: Changed short option of --skip-delete and --skip-update to be more logical storage/maria/ma_test_recovery.expected: Updated results after adding more tests storage/maria/ma_test_recovery: Abort test nicely if we are runnning without debugging Added more tests Changed temporary file names so that one can run maria_chk on them Removed some old comments storage/maria/maria_read_log.c: Added note if maria_read_log will not be able to create byte-to-byte identical tables compared to normal execution storage/maria/unittest/ma_pagecache_consist.c: Removed wrong setting of buff that caused memory overwrite Use my_chmod() instead of chmod() Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable storage/maria/unittest/ma_pagecache_single.c: Use my_chmod() instead of chmod() Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable storage/maria/unittest/ma_test_loghandler_first_lsn-t.c: No reason to test if file exists before we delete it storage/maria/unittest/ma_test_loghandler_multithread-t.c: Don't test result value of pthread_mutex_lock() and pthread_mutex_unlock() as this is not portable storage/maria/unittest/ma_test_loghandler_noflush-t.c: No reason to test if file exists before we delete it storage/maria/unittest/ma_test_loghandler_nologs-t.c: Use my_access() instead of my_stat() to test if file exists storage/maria/unittest/ma_test_loghandler_pagecache-t.c: No reason to test if file exists before we delete it chmod -> my_chmod mysys/my_chmod.c: Added wrapper for chmod()
180 lines
4.8 KiB
C
180 lines
4.8 KiB
C
#include "../maria_def.h"
|
|
#include <stdio.h>
|
|
#include <errno.h>
|
|
#include <tap.h>
|
|
#include "../trnman.h"
|
|
|
|
extern my_bool maria_log_remove();
|
|
extern void example_loghandler_init();
|
|
|
|
#ifndef DBUG_OFF
|
|
static const char *default_dbug_option;
|
|
#endif
|
|
|
|
#define PCACHE_SIZE (1024*1024*10)
|
|
#define PCACHE_PAGE TRANSLOG_PAGE_SIZE
|
|
#define LOG_FILE_SIZE (8*1024L*1024L)
|
|
#define LOG_FLAGS 0
|
|
#define LONG_BUFFER_SIZE (LOG_FILE_SIZE + LOG_FILE_SIZE / 2)
|
|
|
|
|
|
int main(int argc __attribute__((unused)), char *argv[])
|
|
{
|
|
ulong i;
|
|
uint pagen;
|
|
uchar long_tr_id[6];
|
|
PAGECACHE pagecache;
|
|
LSN lsn;
|
|
LEX_STRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
|
uchar *long_buffer= malloc(LONG_BUFFER_SIZE);
|
|
|
|
MY_INIT(argv[0]);
|
|
|
|
plan(2);
|
|
|
|
bzero(&pagecache, sizeof(pagecache));
|
|
bzero(long_buffer, LONG_BUFFER_SIZE);
|
|
maria_data_root= ".";
|
|
if (maria_log_remove())
|
|
exit(1);
|
|
|
|
bzero(long_tr_id, 6);
|
|
#ifndef DBUG_OFF
|
|
#if defined(__WIN__)
|
|
default_dbug_option= "d:t:i:O,\\ma_test_loghandler.trace";
|
|
#else
|
|
default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler.trace";
|
|
#endif
|
|
if (argc > 1)
|
|
{
|
|
DBUG_SET(default_dbug_option);
|
|
DBUG_SET_INITIAL(default_dbug_option);
|
|
}
|
|
#endif
|
|
|
|
if (ma_control_file_create_or_open(TRUE))
|
|
{
|
|
fprintf(stderr, "Can't init control file (%d)\n", errno);
|
|
exit(1);
|
|
}
|
|
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
|
|
PCACHE_PAGE, 0)) == 0)
|
|
{
|
|
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
|
|
exit(1);
|
|
}
|
|
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
|
|
LOG_FLAGS, 0, &translog_example_table_init,
|
|
0))
|
|
{
|
|
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
|
|
exit(1);
|
|
}
|
|
/* Suppressing of automatic record writing */
|
|
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
|
|
|
|
/* write more then 1 file */
|
|
int4store(long_tr_id, 0);
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
|
if (translog_write_record(&lsn,
|
|
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
|
&dummy_transaction_object, NULL, 6,
|
|
TRANSLOG_INTERNAL_PARTS + 1,
|
|
parts, NULL, NULL))
|
|
{
|
|
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
|
|
translog_destroy();
|
|
exit(1);
|
|
}
|
|
|
|
for(i= 0; i < LOG_FILE_SIZE/6 && LSN_FILE_NO(lsn) == 1; i++)
|
|
{
|
|
if (translog_write_record(&lsn,
|
|
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
|
&dummy_transaction_object, NULL, 6,
|
|
TRANSLOG_INTERNAL_PARTS + 1,
|
|
parts, NULL, NULL))
|
|
{
|
|
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
|
|
translog_destroy();
|
|
exit(1);
|
|
}
|
|
}
|
|
|
|
translog_destroy();
|
|
end_pagecache(&pagecache, 1);
|
|
ma_control_file_end();
|
|
|
|
{
|
|
char file_name[FN_REFLEN];
|
|
for (i= 1; i <= 2; i++)
|
|
{
|
|
translog_filename_by_fileno(i, file_name);
|
|
if (my_access(file_name, W_OK))
|
|
{
|
|
fprintf(stderr, "No file '%s'\n", file_name);
|
|
exit(1);
|
|
}
|
|
if (my_delete(file_name, MYF(MY_WME)) != 0)
|
|
{
|
|
fprintf(stderr, "Error %d during removing file'%s'\n",
|
|
errno, file_name);
|
|
exit(1);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (ma_control_file_create_or_open(TRUE))
|
|
{
|
|
fprintf(stderr, "Can't init control file (%d)\n", errno);
|
|
exit(1);
|
|
}
|
|
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
|
|
PCACHE_PAGE, 0)) == 0)
|
|
{
|
|
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
|
|
exit(1);
|
|
}
|
|
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
|
|
LOG_FLAGS, 0, &translog_example_table_init,
|
|
1))
|
|
{
|
|
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
|
|
exit(1);
|
|
}
|
|
/* Suppressing of automatic record writing */
|
|
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
|
|
|
|
ok(1, "Log init OK");
|
|
|
|
int4store(long_tr_id, 0);
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
|
if (translog_write_record(&lsn,
|
|
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
|
&dummy_transaction_object, NULL, 6,
|
|
TRANSLOG_INTERNAL_PARTS + 1,
|
|
parts, NULL, NULL))
|
|
{
|
|
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
|
|
translog_destroy();
|
|
exit(1);
|
|
}
|
|
|
|
translog_destroy();
|
|
end_pagecache(&pagecache, 1);
|
|
ma_control_file_end();
|
|
|
|
if (!translog_is_file(3))
|
|
{
|
|
fprintf(stderr, "No file #3\n");
|
|
exit(1);
|
|
}
|
|
|
|
ok(1, "New log is OK");
|
|
|
|
if (maria_log_remove())
|
|
exit(1);
|
|
exit(0);
|
|
}
|