mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 12:32:27 +01:00
126c1228f5
Will in future changeset (soon) av versioning of status variables (number of rows) and index Changed some LEX_STRING to LEX_CUSTRING to avoid casts and warnings Removed some not needed variables (as noticed by Guilhem) include/maria.h: Added prototypes for maria_chk_init_for_check(), maria_versioning() and maria_ignore_trids() include/my_base.h: Add new error HA_ERR_ROW_NOT_VISIBLE include/myisamchk.h: Added variables for checking visibility of rows during maria_chk include/thr_lock.h: Changed argument type from int to my_bool for get_status Added variable allow_multiple_concurrent_insert, to signal if table supports multiple concurrent inserts mysql-test/r/maria-page-checksum.result: Added missing drop table mysql-test/t/maria-page-checksum.test: Added missing drop table mysys/my_handler.c: Added new error messages mysys/thr_lock.c: Added support for multiple concurrent inserts, if table handler supports it sql/sql_yacc.yy: Added LOCK TABLE table_name WRITE CONCURRENT This was added (temporarly?) to be able to check versioning with Maria storage/csv/ha_tina.cc: Updated parameter for get_status storage/maria/ha_maria.cc: Added calls to maria_chk_init_status() Fixed call to ma_control_file_open() storage/maria/ma_blockrec.c: Changed some LEX_STRING to LEX_CUSTRING to avoid casts and warnings Changed back some 'header' parameters to const char* Removed some casts Added support for versioning: - If info->row_flag & ROW_FLAG_TRANSID is set, store transaction id together with the row - When reading rows, check if rows are visible. Give error if not - When scanning table, ignore not visible rows - Added function parameters to some functions, to be able to call _ma_compact_block_page() with different parameters depending of if the page is a HEAD or TAIL page - _ma_compact_block_page() deletes transaction id's that are visible by all running transactions - Added functions for thr_lock() to enable multiple concurrent inserts - Added helper function 'mysql_versioning()' to enable/disable versioning - Added helper function maria_ignore_trids(), used by maria_chk and maria_pack to see all rows. storage/maria/ma_blockrec.h: Updated parameters for some functions. Added new functions to read/store state with thr_lock storage/maria/ma_check.c: Enable handling of transaction id's in rows Give a readable error if a table contains a transation id that makes rows not visible storage/maria/ma_control_file.c: Added option to not give warning if control file doesn't exists. storage/maria/ma_control_file.h: Updated parameter lists for ma_control_file_open() storage/maria/ma_delete.c: Removed not used variable (suggestion by Guilhem) storage/maria/ma_locking.c: Changed type of argument from int -> my_bool storage/maria/ma_open.c: Removed not used variables 'key_write_undo_lsn' and 'key_delete_undo_lsn' Added new thr_lock interface functions for BLOCK_RECORD to enable multiple concurrent insert storage/maria/ma_test1.c: Added option --versioning (-C) to check versioning storage/maria/ma_test2.c: Added option -C to check versioning storage/maria/ma_test_recovery: Forward argumetns to ma_test_recovery.pl storage/maria/ma_write.c: Removed not used variable key_write_undo_lsn storage/maria/maria_chk.c: Always read control file (if exist) at start Initialize checking of tables by calling maria_chk_init_for_check() In verbose mode and in case of error, print max found transaction id storage/maria/maria_def.h: Added Trid to MARIA_ROW to be able to check transaction id for found row Moved 'base_length' from MARIA_ROW to MARIA_HA to be able to handle different base length (with and without TRANSID) without if's Added default row_flag to MARIA_HA for the same reason Changed LEX_STRING -> LEX_CUSTRING to avoid casts in ma_blockrec.c Removed not needed variables key_write_undo_lsn and key_delete_undo_lsn Added prototypes for new functions and fixed those that had changed storage/maria/maria_pack.c: Ensure we can read all rows from the file, independent of the used transaction id storage/maria/maria_read_log.c: Updated arguments to ma_control_file_open() storage/maria/trnman.c: If we have only one transaction, fixed that min_read_from contains current transaction Fixed that trnman_can_read_from() returns that row is readable if it was written by current transaction storage/maria/unittest/ma_control_file-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_all-t: Added test of versioning Removed printing of one extra space storage/maria/unittest/ma_test_loghandler-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_first_lsn-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_max_lsn-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_multithread-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_noflush-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_nologs-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_loghandler_purge-t.c: Updated arguments to ma_control_file_open() storage/maria/unittest/ma_test_recovery.expected: Updated file with result from new tests storage/maria/unittest/ma_test_recovery.pl: Added options --abort-on-error and --verbose In case of --verbose, print all excuted shell commands Added test of versioning storage/myisam/mi_locking.c: Updated type of parameter storage/myisam/myisamdef.h: Updated type of parameter mysql-test/r/maria-mvcc.result: New BitKeeper file ``mysql-test/r/maria-mvcc.result'' mysql-test/t/maria-mvcc.test: New BitKeeper file ``mysql-test/t/maria-mvcc.test''
195 lines
5.5 KiB
C
195 lines
5.5 KiB
C
/* Copyright (C) 2006-2008 MySQL AB
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
#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_CUSTRING 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= (char *)".";
|
|
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_open(TRUE, 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_open(TRUE, 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);
|
|
}
|