mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 15:24:16 +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''
200 lines
5.8 KiB
C
200 lines
5.8 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 translog_example_table_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 (1024L*1024L*1024L + 1024L*1024L*512)
|
|
#define LOG_FLAGS 0
|
|
|
|
static char *first_translog_file= (char*)"maria_log.00000001";
|
|
static char *file1_name= (char*)"page_cache_test_file_1";
|
|
static PAGECACHE_FILE file1;
|
|
|
|
|
|
/**
|
|
@brief Dummy pagecache callback.
|
|
*/
|
|
|
|
static my_bool
|
|
dummy_callback(uchar *page __attribute__((unused)),
|
|
pgcache_page_no_t page_no __attribute__((unused)),
|
|
uchar* data_ptr __attribute__((unused)))
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
|
|
/**
|
|
@brief Dummy pagecache callback.
|
|
*/
|
|
|
|
static void
|
|
dummy_fail_callback(uchar* data_ptr __attribute__((unused)))
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
int main(int argc __attribute__((unused)), char *argv[])
|
|
{
|
|
uint pagen;
|
|
uchar long_tr_id[6];
|
|
PAGECACHE pagecache;
|
|
LSN lsn;
|
|
my_off_t file_size;
|
|
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
|
|
|
MY_INIT(argv[0]);
|
|
|
|
plan(1);
|
|
|
|
bzero(&pagecache, sizeof(pagecache));
|
|
maria_data_root= (char *)".";
|
|
if (maria_log_remove())
|
|
exit(1);
|
|
/* be sure that we have no logs in the directory*/
|
|
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
|
|
my_delete(first_translog_file, MYF(0));
|
|
|
|
bzero(long_tr_id, 6);
|
|
#ifndef DBUG_OFF
|
|
#if defined(__WIN__)
|
|
default_dbug_option= "d:t:i:O,\\ma_test_loghandler_pagecache.trace";
|
|
#else
|
|
default_dbug_option= "d:t:i:o,/tmp/ma_test_loghandler_pagecache.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;
|
|
|
|
if ((file1.file= my_open(first_translog_file, O_RDONLY, MYF(MY_WME))) < 0)
|
|
{
|
|
fprintf(stderr, "There is no %s (%d)\n", first_translog_file, errno);
|
|
exit(1);
|
|
}
|
|
file_size= my_seek(file1.file, 0, SEEK_END, MYF(MY_WME));
|
|
if (file_size != TRANSLOG_PAGE_SIZE)
|
|
{
|
|
fprintf(stderr,
|
|
"incorrect initial size of %s: %ld instead of %ld\n",
|
|
first_translog_file, (long)file_size, (long)TRANSLOG_PAGE_SIZE);
|
|
exit(1);
|
|
}
|
|
my_close(file1.file, MYF(MY_WME));
|
|
int4store(long_tr_id, 0);
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].str= (char*)long_tr_id;
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
|
dummy_transaction_object.first_undo_lsn= TRANSACTION_LOGGED_LONG_ID;
|
|
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);
|
|
}
|
|
|
|
if ((file1.file= my_open(file1_name,
|
|
O_CREAT | O_TRUNC | O_RDWR, MYF(0))) == -1)
|
|
{
|
|
fprintf(stderr, "Got error during file1 creation from open() (errno: %d)\n",
|
|
errno);
|
|
exit(1);
|
|
}
|
|
pagecache_file_init(file1, &dummy_callback, &dummy_callback,
|
|
&dummy_fail_callback, maria_flush_log_for_page, NULL);
|
|
if (my_chmod(file1_name, S_IRWXU | S_IRWXG | S_IRWXO, MYF(MY_WME)))
|
|
exit(1);
|
|
|
|
{
|
|
uchar page[PCACHE_PAGE];
|
|
|
|
bzero(page, PCACHE_PAGE);
|
|
lsn_store(page, lsn);
|
|
pagecache_write(&pagecache, &file1, 0, 3, page,
|
|
PAGECACHE_LSN_PAGE,
|
|
PAGECACHE_LOCK_LEFT_UNLOCKED,
|
|
PAGECACHE_PIN_LEFT_UNPINNED,
|
|
PAGECACHE_WRITE_DELAY,
|
|
0, LSN_IMPOSSIBLE);
|
|
flush_pagecache_blocks(&pagecache, &file1, FLUSH_FORCE_WRITE);
|
|
}
|
|
my_close(file1.file, MYF(MY_WME));
|
|
if ((file1.file= my_open(first_translog_file, O_RDONLY, MYF(MY_WME))) < 0)
|
|
{
|
|
fprintf(stderr, "can't open %s (%d)\n", first_translog_file, errno);
|
|
exit(1);
|
|
}
|
|
file_size= my_seek(file1.file, 0, SEEK_END, MYF(MY_WME));
|
|
if (file_size != TRANSLOG_PAGE_SIZE * 2)
|
|
{
|
|
fprintf(stderr,
|
|
"incorrect initial size of %s: %ld instead of %ld\n",
|
|
first_translog_file,
|
|
(long)file_size, (long)(TRANSLOG_PAGE_SIZE * 2));
|
|
ok(0, "log triggered");
|
|
exit(1);
|
|
}
|
|
my_close(file1.file, MYF(MY_WME));
|
|
ok(1, "log triggered");
|
|
|
|
translog_destroy();
|
|
end_pagecache(&pagecache, 1);
|
|
ma_control_file_end();
|
|
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
|
|
my_delete(first_translog_file, MYF(0));
|
|
my_delete(file1_name, MYF(0));
|
|
|
|
exit(0);
|
|
}
|