2008-03-04 12:58:21 +01:00
|
|
|
/* 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 */
|
|
|
|
|
2007-08-13 15:17:49 +03:00
|
|
|
#include "../maria_def.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <tap.h>
|
|
|
|
#include "../trnman.h"
|
|
|
|
|
|
|
|
extern my_bool maria_log_remove();
|
2007-12-15 19:16:41 +02:00
|
|
|
extern void translog_example_table_init();
|
2007-08-13 15:17:49 +03:00
|
|
|
|
|
|
|
#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";
|
|
|
|
|
|
|
|
int main(int argc __attribute__((unused)), char *argv[])
|
|
|
|
{
|
|
|
|
uint pagen;
|
|
|
|
int rc= 1;
|
|
|
|
uchar long_tr_id[6];
|
|
|
|
PAGECACHE pagecache;
|
|
|
|
LSN first_lsn;
|
|
|
|
TRANSLOG_HEADER_BUFFER rec;
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
LEX_CUSTRING parts[TRANSLOG_INTERNAL_PARTS + 1];
|
2008-01-10 13:21:53 +01:00
|
|
|
translog_size_t len;
|
2007-08-13 15:17:49 +03:00
|
|
|
|
|
|
|
MY_INIT(argv[0]);
|
|
|
|
|
|
|
|
plan(1);
|
|
|
|
|
|
|
|
bzero(&pagecache, sizeof(pagecache));
|
2008-01-30 08:01:45 +02:00
|
|
|
maria_data_root= (char *)".";
|
2007-08-13 15:17:49 +03:00
|
|
|
if (maria_log_remove())
|
|
|
|
exit(1);
|
|
|
|
/* be sure that we have no logs in the directory*/
|
2008-01-03 09:45:46 +02:00
|
|
|
my_delete(CONTROL_FILE_BASE_NAME, MYF(0));
|
|
|
|
my_delete(first_translog_file, MYF(0));
|
2007-08-13 15:17:49 +03:00
|
|
|
|
|
|
|
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
|
|
|
|
|
Added versioning of row data
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''
2008-04-10 05:26:36 +03:00
|
|
|
if (ma_control_file_open(TRUE, TRUE))
|
2007-08-13 15:17:49 +03:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't init control file (%d)\n", errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
if ((pagen= init_pagecache(&pagecache, PCACHE_SIZE, 0, 0,
|
2007-12-04 23:23:42 +02:00
|
|
|
PCACHE_PAGE, 0)) == 0)
|
2007-08-13 15:17:49 +03:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Got error: init_pagecache() (errno: %d)\n", errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-12-15 15:44:29 +02:00
|
|
|
if (translog_init_with_table(".", LOG_FILE_SIZE, 50112, 0, &pagecache,
|
2007-12-21 15:25:30 +02:00
|
|
|
LOG_FLAGS, 0, &translog_example_table_init,
|
|
|
|
0))
|
2007-08-13 15:17:49 +03:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't init loghandler (%d)\n", errno);
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-09-04 22:52:32 +03:00
|
|
|
/* Suppressing of automatic record writing */
|
|
|
|
dummy_transaction_object.first_undo_lsn|= TRANSACTION_LOGGED_LONG_ID;
|
2007-08-13 15:17:49 +03:00
|
|
|
|
|
|
|
int4store(long_tr_id, 0);
|
|
|
|
long_tr_id[5]= 0xff;
|
2008-08-06 16:03:27 +02:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].str= long_tr_id;
|
2007-08-13 15:17:49 +03:00
|
|
|
parts[TRANSLOG_INTERNAL_PARTS + 0].length= 6;
|
|
|
|
if (translog_write_record(&first_lsn,
|
|
|
|
LOGREC_FIXED_RECORD_0LSN_EXAMPLE,
|
|
|
|
&dummy_transaction_object, NULL, 6,
|
|
|
|
TRANSLOG_INTERNAL_PARTS + 1,
|
WL#3072 - Maria recovery.
* Recovery of the table's live checksum (CREATE TABLE ... CHECKSUM=1)
is achieved in this patch. The table's live checksum
(info->s->state.state.checksum) is updated in inwrite_rec_hook's
under the log mutex when writing UNDO_ROW_INSERT|UPDATE|DELETE
and REDO_DELETE_ALL. The checksum variation caused by the operation
is stored in these UNDOs, so that the REDO phase, when it sees such
UNDOs, can update the live checksum if it is older (state.is_of_lsn is
lower) than the record. It is also used, as a nice add-on with no
cost, to do less row checksum computation during the UNDO phase
(as we have it in the record already).
Doing this work, it became pressing to move in-write hooks
(write_hook_for_redo() et al) to ma_blockrec.c.
The 'parts' argument of inwrite_rec_hook is unpredictable (it comes
mangled at this stage, for example by LSN compression) so it is
replaced by a 'void* hook_arg', which is used to pass down information,
currently only to write_hook_for_clr_end() (previous undo_lsn and
type of undone record).
* If from ha_maria, we print to stderr how many seconds (with one
fractional digit) the REDO phase took, same for UNDO phase and for
final table close. Just to give an indication for debugging and maybe
also for Support.
storage/maria/ha_maria.cc:
question for Monty
storage/maria/ma_blockrec.c:
* log in-write hooks (write_hook_for_redo() etc) move from
ma_loghandler.c to here; this is natural: the hooks are coupled
to their callers (functions in ma_blockrec.c).
* translog_write_record() now has a new argument "hook_arg";
using it to pass down to write_hook_for_clr_end() the transaction's
previous_undo_lsn and the type of the being undone record, and also
to pass down to all UNDOs the live checksum variation caused by the
operation.
* If table has live checksum, store in UNDO_ROW_INSERT|UPDATE|DELETE
and in CLR_END the checksum variation ("delta") caused by the
operation. For example if a DELETE caused the table's live checksum
to change from 123 to 456, we store in the UNDO_ROW_DELETE, in 4 bytes,
the value 333 (456-123).
* Instead of hard-coded "1" as length of the place where we store
the undone record's type in CLR_END, use a symbol CLR_TYPE_STORE_SIZE;
use macros clr_type_store and clr_type_korr.
* write_block_record() has a new parameter 'old_record_checksum'
which is the pre-computed checksum of old_record; that value is used
to update the table's live checksum when writing UNDO_ROW_UPDATE|CLR_END.
* In allocate_write_block_record(), if we are executing UNDO_ROW_DELETE
the row's checksum is already computed.
* _ma_update_block_record2() now expect the new row's checksum into
cur_row.checksum (was already true) and the old row's checksum into
new_row.checksum (that's new). Its two callers, maria_update() and
_ma_apply_undo_row_update(), honour this.
* When executing an UNDO_ROW_INSERT|UPDATE|DELETE in UNDO phase, pick
up the checksum delta from the log record. It is then used to update
the table's live checksum when writing CLR_END, and saves us a
computation of record.
storage/maria/ma_blockrec.h:
in-write hooks move from ma_loghandler.c
storage/maria/ma_check.c:
more straightforward size of buffer
storage/maria/ma_checkpoint.c:
<= is enough
storage/maria/ma_commit.c:
new prototype of translog_write_record()
storage/maria/ma_create.c:
new prototype of translog_write_record()
storage/maria/ma_delete.c:
The row's checksum must be computed before calling(*delete_record)(),
not after, because it must be known inside _ma_delete_block_record()
(to update the table's live checksum when writing UNDO_ROW_DELETE).
If deleting from a transactional table, live checksum was already updated
when writing UNDO_ROW_DELETE.
storage/maria/ma_delete_all.c:
@todo is now done (in ma_loghandler.c)
storage/maria/ma_delete_table.c:
new prototype of translog_write_record()
storage/maria/ma_loghandler.c:
* in-write hooks move to ma_blockrec.c.
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
* fix for compiler warning (unused buffer_start when compiling without
debug support)
* Because checksum delta is stored into UNDO_ROW_INSERT|UPDATE|DELETE
and CLR_END, but only if the table has live checksum, these records
are not PSEUDOFIXEDLENGTH anymore, they are now VARIABLE_LENGTH (their
length is X if no live checksum and X+4 otherwise).
* add an inwrite_rec_hook for UNDO_ROW_UPDATE, which updates the
table's live checksum. Update it also in hooks of UNDO_ROW_INSERT|
DELETE and REDO_DELETE_ALL and CLR_END.
* Bugfix: when reading a record in translog_read_record(), it happened
that "length" became negative, because the function assumed that
the record extended beyond the page's end, whereas it may be shorter.
storage/maria/ma_loghandler.h:
* Instead of hard-coded "1" and "4", use symbols and macros
to store/retrieve the type of record which the CLR_END corresponds
to, and the checksum variation caused by the operation which logs the
record
* translog_write_record() gets a new argument 'hook_arg' which is
passed down to pre|inwrite_rec_hook. It is more useful that 'parts'
for those hooks, because when those hooks are called, 'parts' has
possibly been mangled (like with LSN compression) and is so
unpredictable.
storage/maria/ma_open.c:
fix for "empty body in if() statement" (when compiling without safemutex)
storage/maria/ma_pagecache.c:
<= is enough
storage/maria/ma_recovery.c:
* print the time that each recovery phase (REDO/UNDO/flush) took;
this is enabled only when recovering from ha_maria. Is it printed
n seconds with a fractional part of one digit (like 123.4 seconds).
* In the REDO phase, update the table's live checksum by using
the checksum delta stored in UNDO_ROW_INSERT|DELETE|UPDATE and CLR_END.
Update it too when seeing REDO_DELETE_ALL.
* In the UNDO phase, when executing UNDO_ROW_INSERT, if the table does
not have live checksum then reading the record's header (as done by
the master loop of run_undo_phase()) is enough; otherwise we
do a translog_read_record() to have the checksum delta ready
for _ma_apply_undo_row_insert().
* When at the end of the REDO phase we notice that there is an unfinished
group of REDOs, don't assert in debug binaries, as I verified that it
can happen in real life (with kill -9)
* removing ' in #error as it confuses gcc3
storage/maria/ma_rename.c:
new prototype of translog_write_record()
storage/maria/ma_test_recovery.expected:
Change in output of ma_test_recovery: now all live checksums of
original tables equal those of tables recreated by the REDO phase
and those of tables fixed by the UNDO phase. I.e. recovery of
the live checksum looks like working (which was after all the only
goal of this changeset).
I checked by hand that it's not just all live checksums which are
now 0 and that's why they match. They are the old values like
3757530372. maria.test has hard-coded checksum values in its result
file so checks this too.
storage/maria/ma_update.c:
* It's useless to put up HA_STATE_CHANGED in 'key_changed',
as we put up HA_STATE_CHANGED in info->update anyway.
* We need to compute the old and new rows' checksum before calling
(*update_record)(), as checksum delta must be known when logging
UNDO_ROW_UPDATE which is done by _ma_update_block_record(). Note that
some functions change the 'newrec' record (at least _ma_check_unique()
does) so we cannot move the checksum computation too early in the
function.
storage/maria/ma_write.c:
If inserting into a transactional table, live's checksum was
already updated when writing UNDO_ROW_INSERT. The multiplication
is a trick to save an if().
storage/maria/unittest/ma_test_loghandler-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
new prototype of translog_write_record()
storage/maria/unittest/ma_test_loghandler_purge-t.c:
new prototype of translog_write_record()
storage/myisam/sort.c:
fix for compiler warnings in pushbuild (write_merge_key* functions
didn't have their declaration match MARIA_HA::write_key).
2007-10-02 18:02:09 +02:00
|
|
|
parts, NULL, NULL))
|
2007-08-13 15:17:49 +03:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Can't write record #%lu\n", (ulong) 0);
|
|
|
|
translog_destroy();
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2008-01-10 13:21:53 +01:00
|
|
|
len= translog_read_record_header(first_lsn, &rec);
|
2007-08-13 15:17:49 +03:00
|
|
|
if (len == 0)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "translog_read_record_header failed (%d)\n", errno);
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
if (rec.type !=LOGREC_FIXED_RECORD_0LSN_EXAMPLE || rec.short_trid != 0 ||
|
|
|
|
rec.record_length != 6 || uint4korr(rec.header) != 0 ||
|
|
|
|
((uchar)rec.header[4]) != 0 || ((uchar)rec.header[5]) != 0xFF ||
|
|
|
|
first_lsn != rec.lsn)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "Incorrect LOGREC_FIXED_RECORD_0LSN_EXAMPLE "
|
|
|
|
"data read(0)\n"
|
|
|
|
"type: %u (%d) strid: %u (%d) len: %u (%d) i: %u (%d), "
|
|
|
|
"4: %u (%d) 5: %u (%d) "
|
|
|
|
"lsn(%lu,0x%lx) (%d)\n",
|
|
|
|
(uint) rec.type, (rec.type !=LOGREC_FIXED_RECORD_0LSN_EXAMPLE),
|
|
|
|
(uint) rec.short_trid, (rec.short_trid != 0),
|
|
|
|
(uint) rec.record_length, (rec.record_length != 6),
|
|
|
|
(uint) uint4korr(rec.header), (uint4korr(rec.header) != 0),
|
|
|
|
(uint) rec.header[4], (((uchar)rec.header[4]) != 0),
|
|
|
|
(uint) rec.header[5], (((uchar)rec.header[5]) != 0xFF),
|
2007-09-13 10:37:51 +03:00
|
|
|
LSN_IN_PARTS(rec.lsn), (first_lsn != rec.lsn));
|
2007-08-13 15:17:49 +03:00
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
|
|
|
ok(1, "read OK");
|
|
|
|
rc= 0;
|
|
|
|
|
|
|
|
err:
|
|
|
|
translog_destroy();
|
|
|
|
end_pagecache(&pagecache, 1);
|
|
|
|
ma_control_file_end();
|
2007-08-19 22:27:43 +03:00
|
|
|
if (maria_log_remove())
|
|
|
|
exit(1);
|
2007-08-13 15:17:49 +03:00
|
|
|
|
|
|
|
exit(rc);
|
|
|
|
}
|