mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 05:22:25 +01:00
8f39541e7d
Added logging and pinning of pages to block format. Integration of transaction manager, log handler. Better page cache intergration Split trnman.h into two files, so that we don't have to include my_atomic.h into C++ programs. Renaming of structures, more comments, more debugging etc. Fixed problem with small head block + long varchar. Added extra argument to delete_record() and update_record() (needed for UNDO logging) Small changes to interface of pagecache and log handler. Change initialization of log_record_type_descriptors to not be depending on enum order. Use array of LEX_STRING's to send data to log handler Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists. include/lf.h: Interface fixes Rename of structures (Patch from Sergei via Sanja) include/my_atomic.h: More comments include/my_global.h: Added MY_ERRPTR include/pagecache.h: Added undo LSN when unlocking pages mysql-test/r/maria.result: Updated results mysql-test/t/maria.test: Added autocommit around lock tables (Patch from Sanja) mysys/lf_alloc-pin.c: Post-review fixes, simple optimizations More comments Struct slot renames Check amount of memory on stack (Patch from Sergei) mysys/lf_dynarray.c: More comments mysys/lf_hash.c: More comments After review fixes (Patch from Sergei) storage/maria/ha_maria.cc: Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program. (Temporary fix to avoid bug in gcc) Move out all deferencing of the transaction structure. Transaction manager integrated (Patch from Sergei) storage/maria/ha_maria.h: Added prototype for start_stmt() storage/maria/lockman.c: Function call rename storage/maria/ma_bitmap.c: Mark deleted pages free from page cache storage/maria/ma_blockrec.c: Offset -> rownr More debugging Fixed problem with small head block + long varchar Added logging of changed pages Added logging of undo (Including only loggging of changed fields in case of update) Added pinning/unpinning of all changed pages More comments Added free_full_pages() as the same code was used in several places. fill_rows_parts() renamed as fill_insert_undo_parts() offset -> rownr Added some optimization of not transactional tables _ma_update_block_record() has new parameter, as we need original row to do efficent undo for update storage/maria/ma_blockrec.h: Added ROW_EXTENTS_ON_STACK Changed prototype for update and delete of row storage/maria/ma_check.c: Added original row to delete_record() call storage/maria/ma_control_file.h: Added ifdefs for C++ storage/maria/ma_delete.c: Added original row to delete_record() call (Needed for efficent undo logging) storage/maria/ma_dynrec.c: Added extra argument to delete_record() and update_record() Removed not used variable storage/maria/ma_init.c: Initialize log handler storage/maria/ma_loghandler.c: Removed not used variable Change initialization of log_record_type_descriptors to not be depending on enum order Use array of LEX_STRING's to send data to log handler storage/maria/ma_loghandler.h: New defines Use array of LEX_STRING's to send data to log handler storage/maria/ma_open.c: Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists. Store in MARIA_SHARE->page_type if pages will have up to date LSN's storage/maria/ma_pagecache.c: Don't decrease number of readers when using pagecache_write()/pagecache_read() In pagecache_write() decrement request count if page was left pinned Added pagecache_delete_pages() Removed some casts Make trace output consistent with rest of code Simplify calling of DBUG_ASSERT(0) Only update LSN if the LSN is bigger than what's already on the page Added LSN parameter pagecache_unpin_page(), pagecache_unpin(), and pagecache_unlock() (Part of patch from Sanja) storage/maria/ma_static.c: Added 'dummy' transaction option to MARIA_INFO so that we can always assume 'trn' exists. Added default page cache storage/maria/ma_statrec.c: Added extra argument to delete_record() and update_record() storage/maria/ma_test1.c: Added option -T for transactions storage/maria/ma_test2.c: Added option -T for transactions storage/maria/ma_test_all.sh: Test with transactions storage/maria/ma_update.c: Changed prototype for update of row storage/maria/maria_def.h: Changed prototype for update & delete of row as block records need to access the old row Store in MARIA_SHARE->page_type if pages will have up to date LSN's Added MARIA_MAX_TREE_LEVELS to allow us to calculate the number of possible pinned pages we may need. Removed not used 'empty_bits_buffer' Added pointer to transaction object Added array for pinned pages Added log_row_parts array for logging of field data. Added MARIA_PINNED_PAGE to store pinned pages storage/maria/trnman.c: Added accessor functions to transaction object Added missing DBUG_RETURN() More debugging More comments Changed // comment of code to #ifdef NOT_USED Transaction manager integrated. Post review fixes Part of patch originally from Sergei storage/maria/trnman.h: Split trnman.h into two files, so that we don't have to include my_atomic.h into the .cc program. (Temporary fix to avoid bug in gcc) storage/maria/unittest/ma_pagecache_single.c: Added missing argument Added SKIP_BIG_TESTS (Patch from Sanja) storage/maria/unittest/ma_test_loghandler-t.c: Test logging with new LEX_STRING parameter (Patch from Sanja) storage/maria/unittest/ma_test_loghandler_multigroup-t.c: Test logging with new LEX_STRING parameter (Patch from Sanja) storage/maria/unittest/ma_test_loghandler_multithread-t.c: Test logging with new LEX_STRING parameter (Patch from Sanja) storage/maria/unittest/ma_test_loghandler_pagecache-t.c: Test logging with new LEX_STRING parameter (Patch from Sanja) storage/maria/unittest/trnman-t.c: Stack overflow detection (Patch from Sergei) unittest/unit.pl: Command-line options --big and --verbose (Patch from Sergei) unittest/mytap/tap.c: Detect --big (Patch from Sergei) unittest/mytap/tap.h: Skip_big_tests and SKIP_BIG_TESTS (Patch from Sergei) storage/maria/trnman_public.h: New BitKeeper file ``storage/maria/trnman_public.h''
304 lines
7 KiB
C
304 lines
7 KiB
C
/* Copyright (C) 2006 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
|
|
|
|
Library for providing TAP support for testing C and C++ was written
|
|
by Mats Kindahl <mats@mysql.com>.
|
|
*/
|
|
|
|
#ifndef TAP_H
|
|
#define TAP_H
|
|
|
|
#include "my_global.h"
|
|
|
|
/*
|
|
@defgroup MyTAP MySQL support for performing unit tests according to
|
|
the Test Anything Protocol (TAP).
|
|
*/
|
|
|
|
#define NO_PLAN (0)
|
|
|
|
/**
|
|
Data about test plan.
|
|
|
|
@ingroup MyTAP_Internal
|
|
|
|
@internal We are using the "typedef struct X { ... } X" idiom to
|
|
create class/struct X both in C and C++.
|
|
*/
|
|
|
|
typedef struct TEST_DATA {
|
|
/**
|
|
Number of tests that is planned to execute.
|
|
|
|
Can be zero (<code>NO_PLAN</code>) meaning that the plan string
|
|
will be printed at the end of test instead.
|
|
*/
|
|
int plan;
|
|
|
|
/** Number of last test that was done or skipped. */
|
|
int last;
|
|
|
|
/** Number of tests that failed. */
|
|
int failed;
|
|
|
|
/** Todo reason. */
|
|
char todo[128];
|
|
} TEST_DATA;
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/**
|
|
Defines whether "big" tests should be skipped.
|
|
|
|
This variable is set by plan() function unless MYTAP_CONFIG environment
|
|
variable is set to the string "big". It is supposed to be used as
|
|
|
|
@code
|
|
if (skip_big_tests) {
|
|
skip(1, "Big test skipped");
|
|
} else {
|
|
ok(life_universe_and_everything() == 42, "The answer is CORRECT");
|
|
}
|
|
@endcode
|
|
|
|
@see SKIP_BIG_TESTS
|
|
*/
|
|
extern int skip_big_tests;
|
|
|
|
/**
|
|
@defgroup MyTAP_API MyTAP API
|
|
|
|
MySQL support for performing unit tests according to TAP.
|
|
|
|
@{
|
|
*/
|
|
|
|
/**
|
|
Set number of tests that is planned to execute.
|
|
|
|
The function also accepts the predefined constant
|
|
<code>NO_PLAN</code>. If the function is not called, it is as if
|
|
it was called with <code>NO_PLAN</code>, i.e., the test plan will
|
|
be printed after all the test lines.
|
|
|
|
The plan() function will install signal handlers for all signals
|
|
that generate a core, so if you want to override these signals, do
|
|
it <em>after</em> you have called the plan() function.
|
|
|
|
It will also set skip_big_tests variable if MYTAP_CONFIG environment
|
|
variable is defined.
|
|
|
|
@see skip_big_tests
|
|
|
|
@param count The planned number of tests to run.
|
|
*/
|
|
|
|
void plan(int count);
|
|
|
|
|
|
/**
|
|
Report test result as a TAP line.
|
|
|
|
Function used to write status of an individual test. Call this
|
|
function in the following manner:
|
|
|
|
@code
|
|
ok(ducks == paddling,
|
|
"%d ducks did not paddle", ducks - paddling);
|
|
@endcode
|
|
|
|
@param pass Zero if the test failed, non-zero if it passed.
|
|
@param fmt Format string in printf() format. NULL is allowed, in
|
|
which case nothing is printed.
|
|
*/
|
|
|
|
void ok(int pass, char const *fmt, ...)
|
|
__attribute__((format(printf,2,3)));
|
|
|
|
|
|
/**
|
|
Skip a determined number of tests.
|
|
|
|
Function to print that <em>how_many</em> tests have been skipped.
|
|
The reason is printed for each skipped test. Observe that this
|
|
function does not do the actual skipping for you, it just prints
|
|
information that tests have been skipped. This function is not
|
|
usually used, but rather the macro @c SKIP_BLOCK_IF, which does the
|
|
skipping for you.
|
|
|
|
It shall be used in the following manner:
|
|
|
|
@code
|
|
if (ducks == 0) {
|
|
skip(2, "No ducks in the pond");
|
|
} else {
|
|
int i;
|
|
for (i = 0 ; i < 2 ; ++i)
|
|
ok(duck[i] == paddling, "is duck %d paddling?", i);
|
|
}
|
|
@endcode
|
|
|
|
@see SKIP_BLOCK_IF
|
|
|
|
@param how_many Number of tests that are to be skipped.
|
|
@param reason A reason for skipping the tests
|
|
*/
|
|
|
|
void skip(int how_many, char const *reason, ...)
|
|
__attribute__((format(printf,2,3)));
|
|
|
|
|
|
/**
|
|
Helper macro to skip a block of code. The macro can be used to
|
|
simplify conditionally skipping a block of code. It is used in the
|
|
following manner:
|
|
|
|
@code
|
|
SKIP_BLOCK_IF(ducks == 0, 2, "No ducks in the pond")
|
|
{
|
|
int i;
|
|
for (i = 0 ; i < 2 ; ++i)
|
|
ok(duck[i] == paddling, "is duck %d paddling?", i);
|
|
}
|
|
@endcode
|
|
|
|
@see skip
|
|
*/
|
|
|
|
#define SKIP_BLOCK_IF(SKIP_IF_TRUE, COUNT, REASON) \
|
|
if (SKIP_IF_TRUE) skip((COUNT),(REASON)); else
|
|
|
|
|
|
/**
|
|
Helper macro to skip a group of "big" tests. It is used in the following
|
|
manner:
|
|
|
|
@code
|
|
SKIP_BIG_TESTS(1)
|
|
{
|
|
ok(life_universe_and_everything() == 42, "The answer is CORRECT");
|
|
}
|
|
@endcode
|
|
|
|
@see skip_big_tests
|
|
*/
|
|
|
|
#define SKIP_BIG_TESTS(COUNT) \
|
|
if (skip_big_tests) skip((COUNT), "big test"); else
|
|
|
|
|
|
/**
|
|
Print a diagnostics message.
|
|
|
|
@param fmt Diagnostics message in printf() format.
|
|
*/
|
|
|
|
void diag(char const *fmt, ...)
|
|
__attribute__((format(printf,1,2)));
|
|
|
|
|
|
/**
|
|
Print a bail out message.
|
|
|
|
A bail out message can be issued when no further testing can be
|
|
done, e.g., when there are missing dependencies.
|
|
|
|
The test will exit with status 255. This function does not return.
|
|
|
|
@code
|
|
BAIL_OUT("Lost connection to server %s", server_name);
|
|
@endcode
|
|
|
|
@note A bail out message is printed if a signal that generates a
|
|
core is raised.
|
|
|
|
@param fmt Bail out message in printf() format.
|
|
*/
|
|
|
|
void BAIL_OUT(char const *fmt, ...)
|
|
__attribute__((noreturn, format(printf,1,2)));
|
|
|
|
|
|
/**
|
|
Print summary report and return exit status.
|
|
|
|
This function will print a summary report of how many tests passed,
|
|
how many were skipped, and how many remains to do. The function
|
|
should be called after all tests are executed in the following
|
|
manner:
|
|
|
|
@code
|
|
return exit_status();
|
|
@endcode
|
|
|
|
@returns @c EXIT_SUCCESS if all tests passed, @c EXIT_FAILURE if
|
|
one or more tests failed.
|
|
*/
|
|
|
|
int exit_status(void);
|
|
|
|
|
|
/**
|
|
Skip entire test suite.
|
|
|
|
To skip the entire test suite, use this function. It will
|
|
automatically call exit(), so there is no need to have checks
|
|
around it.
|
|
*/
|
|
|
|
void skip_all(char const *reason, ...)
|
|
__attribute__((noreturn, format(printf, 1, 2)));
|
|
|
|
|
|
/**
|
|
Start section of tests that are not yet ready.
|
|
|
|
To start a section of tests that are not ready and are expected to
|
|
fail, use this function and todo_end() in the following manner:
|
|
|
|
@code
|
|
todo_start("Not ready yet");
|
|
ok(is_rocketeering(duck), "Rocket-propelled ducks");
|
|
ok(is_kamikaze(duck), "Kamikaze ducks");
|
|
todo_end();
|
|
@endcode
|
|
|
|
@see todo_end
|
|
|
|
@note
|
|
It is not possible to nest todo sections.
|
|
|
|
@param message Message that will be printed before the todo tests.
|
|
*/
|
|
|
|
void todo_start(char const *message, ...)
|
|
__attribute__((format(printf, 1, 2)));
|
|
|
|
|
|
/**
|
|
End a section of tests that are not yet ready.
|
|
*/
|
|
|
|
void todo_end();
|
|
|
|
/** @} */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* TAP_H */
|