1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-27 18:02:13 +03:00

Merge gweir@bk-internal.mysql.com:/home/bk/mysql-4.0

into mysql.com:/bk/mysql-4.0
This commit is contained in:
greg@mysql.com
2004-02-19 14:56:31 -01:00
89 changed files with 122 additions and 49781 deletions

View File

@ -55,6 +55,7 @@ konstantin@mysql.com
kostja@oak.local kostja@oak.local
lenz@kallisto.mysql.com lenz@kallisto.mysql.com
lenz@mysql.com lenz@mysql.com
marko@hundin.mysql.fi
miguel@hegel.(none) miguel@hegel.(none)
miguel@hegel.br miguel@hegel.br
miguel@hegel.local miguel@hegel.local

View File

@ -1,312 +0,0 @@
/************************************************************************
Test for the client: interactive SQL
(c) 1996-1997 Innobase Oy
Created 2/16/1996 Heikki Tuuri
*************************************************************************/
#include "univ.i"
#include "ib_odbc.h"
#include "mem0mem.h"
#include "sync0sync.h"
#include "os0thread.h"
#include "os0proc.h"
#include "os0sync.h"
#include "srv0srv.h"
ulint n_exited = 0;
char cli_srv_endpoint_name[100];
char cli_user_name[100];
ulint n_warehouses = ULINT_MAX;
ulint n_customers_d = ULINT_MAX;
bool is_tpc_d = FALSE;
ulint n_rounds = ULINT_MAX;
ulint n_users = ULINT_MAX;
ulint startdate = 0;
ulint enddate = 0;
bool own_warehouse = FALSE;
ulint mem_pool_size = ULINT_MAX;
/*************************************************************************
Reads a keywords and a values from an initfile. In case of an error, exits
from the process. */
static
void
cli_read_initfile(
/*==============*/
FILE* initfile) /* in: file pointer */
{
char str_buf[10000];
ulint ulint_val;
srv_read_init_val(initfile, FALSE, "SRV_ENDPOINT_NAME", str_buf,
&ulint_val);
ut_a(ut_strlen(str_buf) < COM_MAX_ADDR_LEN);
ut_memcpy(cli_srv_endpoint_name, str_buf, COM_MAX_ADDR_LEN);
srv_read_init_val(initfile, FALSE, "USER_NAME", str_buf,
&ulint_val);
ut_a(ut_strlen(str_buf) < COM_MAX_ADDR_LEN);
ut_memcpy(cli_user_name, str_buf, COM_MAX_ADDR_LEN);
srv_read_init_val(initfile, TRUE, "MEM_POOL_SIZE", str_buf,
&mem_pool_size);
srv_read_init_val(initfile, TRUE, "N_WAREHOUSES", str_buf,
&n_warehouses);
srv_read_init_val(initfile, TRUE, "N_CUSTOMERS_D", str_buf,
&n_customers_d);
srv_read_init_val(initfile, TRUE, "IS_TPC_D", str_buf,
&is_tpc_d);
srv_read_init_val(initfile, TRUE, "N_ROUNDS", str_buf,
&n_rounds);
srv_read_init_val(initfile, TRUE, "N_USERS", str_buf,
&n_users);
srv_read_init_val(initfile, TRUE, "STARTDATE", str_buf,
&startdate);
srv_read_init_val(initfile, TRUE, "ENDDATE", str_buf,
&enddate);
srv_read_init_val(initfile, TRUE, "OWN_WAREHOUSE", str_buf,
&own_warehouse);
}
/*************************************************************************
Reads configuration info for the client. */
static
void
cli_boot(
/*=====*/
char* name) /* in: the initialization file name */
{
FILE* initfile;
initfile = fopen(name, "r");
if (initfile == NULL) {
printf(
"Error in client booting: could not open initfile whose name is %s!\n",
name);
os_process_exit(1);
}
cli_read_initfile(initfile);
fclose(initfile);
}
/*********************************************************************
Interactive SQL loop. */
static
void
isql(
/*=*/
FILE* inputfile) /* in: input file containing SQL strings,
or stdin */
{
HENV env;
HDBC conn;
RETCODE ret;
HSTMT sql_query;
ulint tm, oldtm;
char buf[1000];
char* str;
ulint count;
ulint n_begins;
ulint len;
ulint n;
ulint i;
ulint n_lines;
ret = SQLAllocEnv(&env);
ut_a(ret == SQL_SUCCESS);
ret = SQLAllocConnect(env, &conn);
ut_a(ret == SQL_SUCCESS);
ret = SQLConnect(conn, (UCHAR*)cli_srv_endpoint_name,
(SWORD)ut_strlen(cli_srv_endpoint_name),
cli_user_name,
(SWORD)ut_strlen(cli_user_name),
(UCHAR*)"password", 8);
ut_a(ret == SQL_SUCCESS);
printf("Connection established\n");
printf("Interactive SQL performs queries by first making a stored\n");
printf("procedure from them, and then calling the procedure.\n");
printf("Put a semicolon after each statement and\n");
printf("end your query with two <enter>s.\n\n");
printf("You can also give a single input file\n");
printf("as a command line argument to isql.\n\n");
printf("In the file separate SQL queries and procedure bodies\n");
printf("by a single empty line. Do not write the final END; into\n");
printf("a procedure body.\n\n");
count = 0;
loop:
count++;
n = 0;
n_lines = 0;
sprintf(buf, "PROCEDURE P%s%lu () IS\nBEGIN ", cli_user_name,
count);
for (;;) {
len = ut_strlen(buf + n) - 1;
n += len;
if (len == 0) {
break;
} else {
sprintf(buf + n, "\n");
n++;
n_lines++;
}
str = fgets(buf + n, 1000, inputfile);
if ((str == NULL) && (inputfile != stdin)) {
/* Reached end-of-file: switch to input from
keyboard */
inputfile = stdin;
break;
}
ut_a(str);
}
if (n_lines == 1) {
/* Empty procedure */
goto loop;
}
/* If the statement is actually the body of a procedure,
erase the first BEGIN from the string: */
n_begins = 0;
for (i = 0; i < n - 5; i++) {
if (ut_memcmp(buf + i, "BEGIN", 5) == 0) {
n_begins++;
}
}
if (n_begins > 1) {
for (i = 0; i < n - 5; i++) {
if (ut_memcmp(buf + i, "BEGIN", 5) == 0) {
/* Erase the first BEGIN: */
ut_memcpy(buf + i, " ", 5);
break;
}
}
}
sprintf(buf + n, "END;\n");
printf("SQL procedure to execute:\n%s\n", buf);
ret = SQLAllocStmt(conn, &sql_query);
ut_a(ret == SQL_SUCCESS);
ret = SQLPrepare(sql_query, (UCHAR*)buf, ut_strlen(buf));
ut_a(ret == SQL_SUCCESS);
ret = SQLExecute(sql_query);
ut_a(ret == SQL_SUCCESS);
sprintf(buf, "{P%s%lu ()}", cli_user_name, count);
ret = SQLAllocStmt(conn, &sql_query);
ut_a(ret == SQL_SUCCESS);
ret = SQLPrepare(sql_query, (UCHAR*)buf, ut_strlen(buf));
ut_a(ret == SQL_SUCCESS);
printf("Starting to execute the query\n");
oldtm = ut_clock();
ret = SQLExecute(sql_query);
tm = ut_clock();
printf("Wall time for query %lu milliseconds\n\n", tm - oldtm);
ut_a(ret == SQL_SUCCESS);
goto loop;
}
/********************************************************************
Main test function. */
void
main(int argc, char* argv[])
/*========================*/
{
ulint tm, oldtm;
FILE* inputfile;
if (argc > 2) {
printf("Only one input file allowed\n");
os_process_exit(1);
} else if (argc == 2) {
inputfile = fopen(argv[1], "r");
if (inputfile == NULL) {
printf(
"Error: could not open the inputfile whose name is %s!\n",
argv[1]);
os_process_exit(1);
}
} else {
inputfile = stdin;
}
cli_boot("cli_init");
sync_init();
mem_init(mem_pool_size);
oldtm = ut_clock();
isql(inputfile);
tm = ut_clock();
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,16 +0,0 @@
include ..\..\makefile.i
doall: tssrv tscli isql
tssrv: ..\btr.lib tssrv.c
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\eval.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tssrv.c $(LFL)
tscli: ..\btr.lib tscli.c
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\ib_odbc.lib ..\..\eval.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tscli.c $(LFL)
isql: ..\btr.lib isql.c
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\ib_odbc.lib ..\..\eval.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib isql.c $(LFL)
tsrecv: ..\btr.lib tsrecv.c
$(CCOM) $(CFL) -I.. -I..\.. ..\btr.lib ..\..\ibuf.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsrecv.c $(LFL)

View File

@ -1,483 +0,0 @@
/************************************************************************
The test module for the record manager of MVB.
(c) 1994 Heikki Tuuri
Created 1/25/1994 Heikki Tuuri
*************************************************************************/
#include "rm0phr.h"
#include "rm0lgr.h"
#include "ut0ut.h"
#include "buf0mem.h"
#include "rm0ipg.h"
#include "../it0it.h"
#include "../it0hi.h"
#include "../it0ads.h"
byte buf[100];
byte buf2[100];
lint lintbuf[2048];
byte numbuf[6000];
byte numlogrecbuf[100];
phr_record_t* qs_table[100000];
lint qs_comp = 0;
extern
void
test1(void);
#ifdef NOT_DEFINED
void
q_sort(lint low, lint up)
{
phr_record_t* temp, *pivot;
lint i, j;
pivot = qs_table[(low + up) / 2];
i = low;
j = up;
while (i < j) {
qs_comp++;
if (cmp_phr_compare(qs_table[i], pivot)<= 0) {
i++;
} else {
j--;
temp = qs_table[i];
qs_table[i] = qs_table[j];
qs_table[j] = temp;
}
}
if (j == up) {
temp = qs_table[(low + up) / 2];
qs_table[(low + up) / 2] = qs_table[up - 1];
qs_table[up - 1] = temp;
j--;
}
if (j - low <= 1) {
/* do nothing */
} else if (j - low == 2) {
qs_comp++;
if (cmp_phr_compare(qs_table[low],
qs_table[low + 1])
<= 0) {
/* do nothing */
} else {
temp = qs_table[low];
qs_table[low] = qs_table[low + 1];
qs_table[low + 1] = temp;
}
} else {
q_sort(low, j);
}
if (up - j <= 1) {
/* do nothing */
} else if (up - j == 2) {
qs_comp++;
if (cmp_phr_compare(qs_table[j],
qs_table[j + 1])
<= 0) {
/* do nothing */
} else {
temp = qs_table[j];
qs_table[j] = qs_table[j + 1];
qs_table[j + 1] = temp;
}
} else {
q_sort(j, up);
}
}
#endif
extern
void
test1(void)
{
phr_record_t* physrec;
phr_record_t* rec1;
phr_record_t* rec2;
lgr_record_t* logrec;
lgrf_field_t* logfield;
lint len;
byte* str;
lint len2;
lint tm;
lint oldtm;
lint i, j, k, l, m;
bool b;
it_cur_cursor_t cursor;
ipg_cur_cursor_t* page_cursor;
ipg_page_t* page;
byte c4, c3, c2, c1, c0;
lint rand, rnd1, rnd2;
byte* nb;
lgr_record_t* numlogrec;
byte* pgbuf;
mem_stream_t* stream;
lint tree1, tree2, tree3;
lint dummy1, dummy2;
pgbuf = (byte*)lintbuf;
stream = mem_stream_create(0);
printf("-------------------------------------------\n");
printf("TEST 1. Speed and basic tests.\n");
logrec = lgr_create_logical_record(stream, 2);
nb = numbuf;
c4 = '0';
c3 = '0';
for (c2 = '0'; c2 <= '9'; c2++) {
for (c1 = '0'; c1 <= '9'; c1++) {
for (c0 = '0'; c0 <= '9'; c0++) {
*nb = c4; nb++;
*nb = c3; nb++;
*nb = c2; nb++;
*nb = c1; nb++;
*nb = c0; nb++;
*nb = '\0'; nb++;
}
}
}
numlogrec = lgr_create_logical_record(stream, 2);
tree1 = it_create_index_tree();
oldtm = ut_clock();
rand = 99900;
rnd1 = 67;
for (j = 0; j < 1; j++) {
for (i = 0 ; i < 100000; i++) {
rand = (rand + 1) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
/*
it_insert(tree1, numlogrec);
*/
it_cur_search_tree_to_nth_level(tree1, 1, numlogrec,
IPG_SE_L_GE, &cursor, &dummy1, &dummy2);
/*
it_cur_set_to_first(tree1, &cursor);
*/
it_cur_insert_record(&cursor, numlogrec);
}
}
tm = ut_clock();
printf("Time for inserting %ld recs = %ld \n", i* j, tm - oldtm);
/* it_print_tree(tree1, 10);*/
hi_print_info();
ads_print_info();
/*
oldtm = ut_clock();
rand = 11113;
for (i = 0; i < 5000; i++) {
rand = (rand + 57123) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
it_cur_search_tree_to_nth_level(tree1, 1, numlogrec,
IPG_SE_L_GE, &cursor, &dummy1, &dummy2);
}
tm = ut_clock();
printf("Time for searching %ld recs = %ld \n", i, tm - oldtm);
*/
it_cur_set_to_first(tree1, &cursor);
rec1 = ipg_cur_get_record(it_cur_get_page_cursor(&cursor));
for (i = 0;; i++) {
it_cur_move_to_next(&cursor);
if (it_cur_end_of_level(&cursor)) {
break;
}
rec2 = ipg_cur_get_record(it_cur_get_page_cursor(&cursor));
ut_a(cmp_phr_compare(rec1, rec2) == -1);
rec1 = rec2;
}
printf("tree1 checked for right sorted order!\n");
#ifdef not_defined
oldtm = ut_clock();
for (j = 0; j < 1; j++) {
rand = 11113;
for (i = 0; i < 3000; i++) {
rand = (rand + 57123) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
physrec = hi_search(numlogrec);
ut_a(physrec);
}
}
ut_a(physrec);
tm = ut_clock();
printf("Time for hi_search %ld recs = %ld \n", i * j,
tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 100000; i++) {
/* j += lgr_fold(numlogrec, -1, -1);*/
/* b += phr_lgr_equal(physrec, numlogrec, -1);*/
k += ut_hash_lint(j, HI_TABLE_SIZE);
}
/* ut_a(b);*/
tm = ut_clock();
printf("Time for fold + equal %ld recs %s = %ld \n", i, physrec,
tm - oldtm);
printf("%ld %ld %ld\n", j, b, k);
hi_print_info();
tree2 = it_create_index_tree();
rand = 90000;
for (i = 0; i < 300; i++) {
rand = (rand + 1) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
it_cur_search_tree_to_nth_level(tree2, 1, numlogrec,
IPG_SE_L_GE, &cursor);
it_cur_insert_record(&cursor, numlogrec);
}
oldtm = ut_clock();
rand = 10000;
for (i = 0; i < 3000; i++) {
rand = (rand + 1) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
it_cur_search_tree_to_nth_level(tree2, 1, numlogrec,
IPG_SE_L_GE, &cursor);
it_cur_insert_record(&cursor, numlogrec);
}
tm = ut_clock();
printf("Time for inserting sequentially %ld recs = %ld \n",
i, tm - oldtm);
/* it_print_tree(tree2, 10); */
tree3 = it_create_index_tree();
rand = 0;
for (i = 0; i < 300; i++) {
rand = (rand + 1) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
it_cur_search_tree_to_nth_level(tree3, 1, numlogrec,
IPG_SE_L_GE, &cursor);
it_cur_insert_record(&cursor, numlogrec);
}
oldtm = ut_clock();
rand = 100000;
for (i = 0; i < 3000; i++) {
rand = (rand - 1) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
it_cur_search_tree_to_nth_level(tree3, 1, numlogrec,
IPG_SE_L_GE, &cursor);
it_cur_insert_record(&cursor, numlogrec);
}
tm = ut_clock();
printf("Time for inserting sequentially downw. %ld recs = %ld \n",
i, tm - oldtm);
/* it_print_tree(tree3, 10); */
#endif
}
#ifdef NOT_DEFINED
/* Test of quicksort */
void
test2(void)
{
mem_stream_t* stream;
byte* stbuf;
lgrf_field_t* logfield;
lint tm;
lint oldtm;
lint i, j, k, l, m;
lint rand;
lgr_record_t* numlogrec;
phr_record_t* ph_rec;
stream = mem_stream_create(1000);
numlogrec = lgr_create_logical_record(stream, 2);
oldtm = ut_clock();
rand = 11113;
for (i = 0; i < 50000; i++) {
stbuf = mem_stream_alloc(stream, 30);
rand = (rand + 57123) % 100000;
logfield = lgr_get_nth_field(numlogrec, 0);
lgrf_set_data(logfield, numbuf + 6 * (rand / 300));
lgrf_set_len(logfield, 6);
logfield = lgr_get_nth_field(numlogrec, 1);
lgrf_set_data(logfield, numbuf + 6 * (rand % 300));
lgrf_set_len(logfield, 6);
ph_rec = phr_create_physical_record(stbuf, 30, numlogrec);
qs_table[i] = ph_rec;
}
tm = ut_clock();
printf("Time for inserting %ld recs to mem stream = %ld \n",
i, tm - oldtm);
oldtm = ut_clock();
q_sort(0, 50000);
tm = ut_clock();
printf("Time for quicksort of %ld recs = %ld, comps: %ld \n",
i, tm - oldtm, qs_comp);
for (i = 1; i < 49999; i++) {
ut_a(-1 ==
cmp_phr_compare(qs_table[i], qs_table[i+1]
));
}
tm = ut_clock();
oldtm = ut_clock();
for (i = 1; i < 50000; i++) {
k += cmp_phr_compare(qs_table[i & 0xF],
qs_table[5]);
}
tm = ut_clock();
printf("%ld\n", k);
printf("Time for cmp of %ld ph_recs = %ld \n",
i, tm - oldtm);
mem_stream_free(stream);
}
#endif
void
main(void)
{
test1();
/* test2(); */
}

View File

@ -1,798 +0,0 @@
/************************************************************************
The test for the index tree
(c) 1994-1996 Innobase Oy
Created 2/16/1996 Heikki Tuuri
*************************************************************************/
#include "sync0sync.h"
#include "ut0mem.h"
#include "mem0mem.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "buf0buf.h"
#include "os0file.h"
#include "fil0fil.h"
#include "fsp0fsp.h"
#include "rem0rec.h"
#include "rem0cmp.h"
#include "mtr0mtr.h"
#include "log0log.h"
#include "page0page.h"
#include "page0cur.h"
#include "..\btr0btr.h"
#include "..\btr0cur.h"
#include "..\btr0pcur.h"
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[10];
mutex_t incs_mutex;
ulint incs;
byte bigbuf[1000000];
#define N_SPACES 1
#define N_FILES 2
#define FILE_SIZE 1000 /* must be > 512 */
#define POOL_SIZE 1000
#define COUNTER_OFFSET 1500
#define LOOP_SIZE 150
#define N_THREADS 5
ulint zero = 0;
buf_block_t* bl_arr[POOL_SIZE];
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Io handler thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = fil_aio_wait(segment, &mess);
ut_a(ret);
buf_page_io_complete((buf_block_t*)mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/*************************************************************************
Creates the files for the file system test and inserts them to
the file system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[20];
os_thread_t thr[5];
os_thread_id_t id[5];
printf("--------------------------------------------------------\n");
printf("Create or open database files\n");
strcpy(name, "j:\\tsfile00");
for (k = 0; k < N_SPACES; k++) {
for (i = 0; i < N_FILES; i++) {
name[9] = (char)((ulint)'0' + k);
name[10] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_TABLESPACE, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k, OS_FILE_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, FILE_SIZE, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
}
/************************************************************************
Inits space header of space 0. */
void
init_space(void)
/*============*/
{
mtr_t mtr;
printf("Init space header\n");
mtr_start(&mtr);
fsp_header_init(0, FILE_SIZE * N_FILES, &mtr);
mtr_commit(&mtr);
}
/*********************************************************************
Test for index page. */
void
test1(void)
/*=======*/
{
dtuple_t* tuple;
mem_heap_t* heap;
ulint rnd = 0;
dict_index_t* index;
dict_table_t* table;
dict_tree_t* tree;
mtr_t mtr;
byte buf[8];
ulint i;
ulint tm, oldtm;
btr_pcur_t cursor;
printf("-------------------------------------------------\n");
printf("TEST 1. Basic test\n");
heap = mem_heap_create(0);
table = dict_mem_table_create("TS_TABLE1", 2);
dict_mem_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_mem_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_table_add_to_cache(table);
index = dict_mem_index_create("TS_TABLE1", "IND1", 0, 2, 0);
dict_mem_index_add_field(index, "COL1", 0);
dict_mem_index_add_field(index, "COL2", 0);
dict_index_add_to_cache(index);
index = dict_index_get("TS_TABLE1", "IND1");
ut_a(index);
tree = dict_index_get_tree(index);
tuple = dtuple_create(heap, 3);
mtr_start(&mtr);
btr_root_create(tree, 0, &mtr);
mtr_commit(&mtr);
mtr_start(&mtr);
dtuple_gen_test_tuple3(tuple, 0, buf);
btr_insert(tree, tuple, &mtr);
mtr_commit(&mtr);
rnd = 90000;
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
if (i == 77000) {
rnd = rnd % 200000;
}
rnd = (rnd + 15675751) % 200000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
btr_insert(tree, tuple, &mtr);
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
rnd = 90000;
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
if (i == 50000) {
rnd = rnd % 200000;
}
rnd = (rnd + 595659561) % 200000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
btr_pcur_open(tree, tuple, PAGE_CUR_GE,
BTR_SEARCH_LEAF, &cursor, &mtr);
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
rnd = 0;
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
rnd = (rnd + 35608971) % 200000 + 1;
dtuple_gen_test_tuple3(tuple, rnd, buf);
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
/* btr_print_tree(tree, 3); */
mem_heap_free(heap);
}
#ifdef notdefined
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
for (i = 0; i < 512; i++) {
rnd = (rnd + 534671) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
/* page_print_list(page, 151); */
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 512);
for (i = 0; i < 512; i++) {
rnd = (rnd + 7771) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_get_n_recs(page) == 0);
ut_a(page_validate(page, index));
page = page_create(frame, &mtr);
rnd = 311;
for (i = 0; i < 512; i++) {
rnd = (rnd + 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 512);
rnd = 217;
for (i = 0; i < 512; i++) {
rnd = (rnd + 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 0);
page = page_create(frame, &mtr);
rnd = 291;
for (i = 0; i < 512; i++) {
rnd = (rnd - 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 512);
rnd = 277;
for (i = 0; i < 512; i++) {
rnd = (rnd - 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 0);
mtr_commit(&mtr);
mem_heap_free(heap);
}
/*********************************************************************
Test for index page. */
void
test2(void)
/*=======*/
{
page_t* page;
dtuple_t* tuple;
mem_heap_t* heap;
ulint i, j;
ulint rnd = 0;
rec_t* rec;
page_cur_t cursor;
dict_index_t* index;
dict_table_t* table;
buf_block_t* block;
buf_frame_t* frame;
ulint tm, oldtm;
byte buf[8];
mtr_t mtr;
printf("-------------------------------------------------\n");
printf("TEST 2. Speed test\n");
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
ut_memcpy(bigbuf, bigbuf + 800, 800);
}
tm = ut_clock();
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
i, tm - oldtm);
oldtm = ut_clock();
rnd = 0;
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
ut_memcpy(bigbuf + rnd, bigbuf + rnd + 800, 800);
rnd += 1600;
if (rnd > 995000) {
rnd = 0;
}
}
tm = ut_clock();
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
i, tm - oldtm);
heap = mem_heap_create(0);
table = dict_table_create("TS_TABLE2", 2);
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
ut_a(0 == dict_table_publish(table));
index = dict_index_create("TS_TABLE2", "IND2", 0, 2, 0);
dict_index_add_field(index, "COL1", 0);
dict_index_add_field(index, "COL2", 0);
ut_a(0 == dict_index_publish(index));
index = dict_index_get("TS_TABLE2", "IND2");
ut_a(index);
tuple = dtuple_create(heap, 2);
oldtm = ut_clock();
rnd = 677;
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
for (j = 0; j < 250; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall time for insertion of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
mtr_start(&mtr);
block = buf_page_get(0, 5, &mtr);
buf_page_s_lock(block, &mtr);
page = buf_block_get_frame(block);
ut_a(page_validate(page, index));
mtr_commit(&mtr);
oldtm = ut_clock();
rnd = 677;
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
for (j = 0; j < 250; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf(
"Wall time for %lu empty loops with page create %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
rnd = 100;
for (j = 0; j < 250; j++) {
rnd = (rnd + 1) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf(
"Wall time for sequential insertion of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
rnd = 500;
for (j = 0; j < 250; j++) {
rnd = (rnd - 1) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf(
"Wall time for descend. seq. insertion of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
rnd = 677;
for (j = 0; j < 250; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
rnd = 677;
for (j = 0; j < 250; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
}
ut_a(page_get_n_recs(page) == 0);
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall time for insert and delete of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
rnd = 677;
for (j = 0; j < 250; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
ut_a(page_validate(page, index));
mtr_print(&mtr);
oldtm = ut_clock();
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
rnd = 677;
for (j = 0; j < 250; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
}
}
tm = ut_clock();
printf("Wall time for search of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
rnd = 677;
for (j = 0; j < 250; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple2(tuple, rnd, buf);
}
}
tm = ut_clock();
printf("Wall time for %lu empty loops %lu milliseconds\n",
i * j, tm - oldtm);
mtr_commit(&mtr);
}
#endif
/********************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
sync_init();
mem_init();
os_aio_init(160, 5);
fil_init(25);
buf_pool_init(POOL_SIZE, POOL_SIZE);
dict_init();
fsp_init();
log_init();
create_files();
init_space();
oldtm = ut_clock();
ut_rnd_set_seed(19);
test1();
/* mem_print_info(); */
tm = ut_clock();
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,802 +0,0 @@
/************************************************************************
Test for the B-tree
(c) 1994-1997 Innobase Oy
Created 2/16/1996 Heikki Tuuri
*************************************************************************/
#include "os0proc.h"
#include "sync0sync.h"
#include "ut0mem.h"
#include "mem0mem.h"
#include "mem0pool.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "buf0buf.h"
#include "os0file.h"
#include "os0thread.h"
#include "fil0fil.h"
#include "fsp0fsp.h"
#include "rem0rec.h"
#include "rem0cmp.h"
#include "mtr0mtr.h"
#include "log0log.h"
#include "page0page.h"
#include "page0cur.h"
#include "trx0trx.h"
#include "dict0boot.h"
#include "trx0sys.h"
#include "dict0crea.h"
#include "btr0btr.h"
#include "btr0pcur.h"
#include "btr0cur.h"
#include "btr0sea.h"
#include "rem0rec.h"
#include "srv0srv.h"
#include "que0que.h"
#include "com0com.h"
#include "usr0sess.h"
#include "lock0lock.h"
#include "trx0roll.h"
#include "trx0purge.h"
#include "row0ins.h"
#include "row0upd.h"
#include "row0row.h"
#include "row0del.h"
#include "lock0lock.h"
#include "ibuf0ibuf.h"
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[10];
mutex_t incs_mutex;
ulint incs;
#define N_SPACES 2 /* must be >= 2 */
#define N_FILES 1
#define FILE_SIZE 8096 /* must be > 512 */
#define POOL_SIZE 1024
#define IBUF_SIZE 200
#define COUNTER_OFFSET 1500
#define LOOP_SIZE 150
#define N_THREADS 5
#define COUNT 1
ulint zero = 0;
buf_block_t* bl_arr[POOL_SIZE];
ulint dummy = 0;
byte test_buf[8000];
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Io handler thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = fil_aio_wait(segment, &mess);
ut_a(ret);
buf_page_io_complete((buf_block_t*)mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/*************************************************************************
Creates the files for the file system test and inserts them to the file
system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[20];
os_thread_t thr[10];
os_thread_id_t id[10];
printf("--------------------------------------------------------\n");
printf("Create or open database files\n");
strcpy(name, "tsfile00");
for (k = 0; k < N_SPACES; k++) {
for (i = 0; i < N_FILES; i++) {
name[6] = (char)((ulint)'0' + k);
name[7] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_TABLESPACE, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
} else {
if (k == 1) {
ut_a(os_file_set_size(files[i],
8192 * IBUF_SIZE, 0));
} else {
ut_a(os_file_set_size(files[i],
8192 * FILE_SIZE, 0));
}
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k, OS_FILE_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, FILE_SIZE, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
mutex_set_level(&ios_mutex, SYNC_NO_ORDER_CHECK);
for (i = 0; i < 9; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
}
/************************************************************************
Inits space headers of spaces 0 and 1. */
void
init_spaces(void)
/*=============*/
{
mtr_t mtr;
mtr_start(&mtr);
fsp_header_init(0, FILE_SIZE * N_FILES, &mtr);
fsp_header_init(1, IBUF_SIZE, &mtr);
mtr_commit(&mtr);
}
/*********************************************************************
Test for table creation. */
ulint
test1(
/*==*/
void* arg)
{
sess_t* sess;
com_endpoint_t* com_endpoint;
mem_heap_t* heap;
dict_index_t* index;
dict_table_t* table;
que_fork_t* fork;
que_thr_t* thr;
trx_t* trx;
UT_NOT_USED(arg);
printf("-------------------------------------------------\n");
printf("TEST 1. CREATE TABLE WITH 3 COLUMNS AND WITH 3 INDEXES\n");
heap = mem_heap_create(512);
com_endpoint = (com_endpoint_t*)heap; /* This is a dummy non-NULL
value */
mutex_enter(&kernel_mutex);
sess = sess_open(ut_dulint_zero, com_endpoint, (byte*)"user1", 6);
trx = sess->trx;
mutex_exit(&kernel_mutex);
ut_a(trx_start(trx, ULINT_UNDEFINED));
table = dict_mem_table_create("TS_TABLE1", 0, 3);
dict_mem_table_add_col(table, "COL1", DATA_VARCHAR,
DATA_ENGLISH, 10, 0);
dict_mem_table_add_col(table, "COL2", DATA_VARCHAR,
DATA_ENGLISH, 10, 0);
dict_mem_table_add_col(table, "COL3", DATA_VARCHAR,
DATA_ENGLISH, 100, 0);
/*------------------------------------*/
/* CREATE TABLE */
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
thr->child = tab_create_graph_create(fork, thr, table, heap);
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
que_run_threads(thr);
/* dict_table_print_by_name("SYS_TABLES");
dict_table_print_by_name("SYS_COLUMNS"); */
/*-------------------------------------*/
/* CREATE CLUSTERED INDEX */
index = dict_mem_index_create("TS_TABLE1", "IND1", 0,
DICT_UNIQUE | DICT_CLUSTERED, 1);
dict_mem_index_add_field(index, "COL1", 0);
ut_a(mem_heap_validate(index->heap));
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
thr->child = ind_create_graph_create(fork, thr, index, heap);
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
que_run_threads(thr);
/* dict_table_print_by_name("SYS_INDEXES");
dict_table_print_by_name("SYS_FIELDS"); */
/*-------------------------------------*/
/* CREATE SECONDARY INDEX */
index = dict_mem_index_create("TS_TABLE1", "IND2", 0, 0, 1);
dict_mem_index_add_field(index, "COL2", 0);
ut_a(mem_heap_validate(index->heap));
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
thr->child = ind_create_graph_create(fork, thr, index, heap);
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
que_run_threads(thr);
/* dict_table_print_by_name("SYS_INDEXES");
dict_table_print_by_name("SYS_FIELDS"); */
/*-------------------------------------*/
/* CREATE ANOTHER SECONDARY INDEX */
index = dict_mem_index_create("TS_TABLE1", "IND3", 0, 0, 1);
dict_mem_index_add_field(index, "COL2", 0);
ut_a(mem_heap_validate(index->heap));
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
thr->child = ind_create_graph_create(fork, thr, index, heap);
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
que_run_threads(thr);
#ifdef notdefined
/*-------------------------------------*/
/* CREATE YET ANOTHER SECONDARY INDEX */
index = dict_mem_index_create("TS_TABLE1", "IND4", 0, 0, 1);
dict_mem_index_add_field(index, "COL2", 0);
ut_a(mem_heap_validate(index->heap));
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
thr->child = ind_create_graph_create(fork, thr, index, heap);
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
que_run_threads(thr);
#endif
/* dict_table_print_by_name("SYS_INDEXES");
dict_table_print_by_name("SYS_FIELDS"); */
return(0);
}
/*********************************************************************
Another test for inserts. */
ulint
test2_1(
/*====*/
void* arg)
{
ulint tm, oldtm;
sess_t* sess;
com_endpoint_t* com_endpoint;
mem_heap_t* heap;
que_fork_t* fork;
dict_table_t* table;
que_thr_t* thr;
trx_t* trx;
ulint i;
byte buf[100];
ins_node_t* node;
ulint count = 0;
ulint rnd;
dtuple_t* row;
dict_index_t* index;
/* dict_tree_t* tree;
dtuple_t* entry;
btr_pcur_t pcur;
mtr_t mtr; */
printf("-------------------------------------------------\n");
printf("TEST 2.1. MASSIVE ASCENDING INSERT\n");
heap = mem_heap_create(512);
com_endpoint = (com_endpoint_t*)heap; /* This is a dummy non-NULL
value */
mutex_enter(&kernel_mutex);
sess = sess_open(ut_dulint_zero, com_endpoint, (byte*)"user1", 6);
trx = sess->trx;
mutex_exit(&kernel_mutex);
loop:
ut_a(trx_start(trx, ULINT_UNDEFINED));
/*-------------------------------------*/
/* MASSIVE INSERT */
fork = que_fork_create(NULL, NULL, QUE_FORK_INSERT, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
table = dict_table_get("TS_TABLE1", trx);
row = dtuple_create(heap, 3 + DATA_N_SYS_COLS);
dict_table_copy_types(row, table);
node = ins_node_create(fork, thr, row, table, heap);
thr->child = node;
row_ins_init_sys_fields_at_sql_compile(node->row, node->table, heap);
row_ins_init_sys_fields_at_sql_prepare(node->row, node->table, trx);
node->init_all_sys_fields = FALSE;
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
mutex_exit(&kernel_mutex);
rnd = 0;
log_print();
oldtm = ut_clock();
for (i = 0; i < *((ulint*)arg); i++) {
dtuple_gen_test_tuple3(row, rnd, DTUPLE_TEST_FIXED30, buf);
mutex_enter(&kernel_mutex);
ut_a(
thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
que_run_threads(thr);
if (i % 5000 == 0) {
/* ibuf_print(); */
/* buf_print(); */
/* buf_print_io(); */
/*
tm = ut_clock();
printf("Wall time for %lu inserts %lu milliseconds\n",
i, tm - oldtm); */
}
rnd = rnd + 1;
}
tm = ut_clock();
printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm);
log_print();
/* dict_table_print_by_name("TS_TABLE1"); */
/* ibuf_print(); */
index = index;
index = dict_table_get_first_index(table);
if (zero) {
btr_search_index_print_info(index);
}
btr_validate_tree(dict_index_get_tree(index));
#ifdef notdefined
index = dict_table_get_next_index(index);
if (zero) {
btr_search_index_print_info(index);
}
btr_validate_tree(dict_index_get_tree(index));
index = dict_table_get_next_index(index);
/* btr_search_index_print_info(index); */
btr_validate_tree(dict_index_get_tree(index));
/* dict_table_print_by_name("TS_TABLE1"); */
/* Check inserted entries */
btr_search_print_info();
entry = dtuple_create(heap, 1);
dtuple_gen_search_tuple3(entry, 0, buf);
mtr_start(&mtr);
index = dict_table_get_first_index(table);
tree = dict_index_get_tree(index);
btr_pcur_open(index, entry, PAGE_CUR_L, BTR_SEARCH_LEAF, &pcur, &mtr);
ut_a(btr_pcur_is_before_first_in_tree(&pcur, &mtr));
for (i = 0; i < *((ulint*)arg); i++) {
ut_a(btr_pcur_move_to_next(&pcur, &mtr));
dtuple_gen_search_tuple3(entry, i, buf);
ut_a(0 == cmp_dtuple_rec(entry, btr_pcur_get_rec(&pcur)));
}
ut_a(!btr_pcur_move_to_next(&pcur, &mtr));
ut_a(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
btr_pcur_close(&pcur);
mtr_commit(&mtr);
printf("Validating tree\n");
btr_validate_tree(tree);
printf("Validated\n");
#endif
/*-------------------------------------*/
/* ROLLBACK */
#ifdef notdefined
/* btr_validate_tree(tree); */
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
thr->child = roll_node_create(fork, thr, heap);
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
oldtm = ut_clock();
que_run_threads(thr);
tm = ut_clock();
printf("Wall time for rollback of %lu inserts %lu milliseconds\n",
i, tm - oldtm);
os_thread_sleep(1000000);
/* dict_table_print_by_name("TS_TABLE1"); */
dtuple_gen_search_tuple3(entry, 0, buf);
mtr_start(&mtr);
btr_pcur_open(index, entry, PAGE_CUR_L, BTR_SEARCH_LEAF, &pcur, &mtr);
ut_a(btr_pcur_is_before_first_in_tree(&pcur, &mtr));
ut_a(!btr_pcur_move_to_next(&pcur, &mtr));
ut_a(btr_pcur_is_after_last_in_tree(&pcur, &mtr));
btr_pcur_close(&pcur);
mtr_commit(&mtr);
btr_search_print_info();
#endif
/*-------------------------------------*/
/* COMMIT */
fork = que_fork_create(NULL, NULL, QUE_FORK_EXECUTE, heap);
fork->trx = trx;
thr = que_thr_create(fork, fork, heap);
thr->child = commit_node_create(fork, thr, heap);
mutex_enter(&kernel_mutex);
que_graph_publish(fork, trx->sess);
trx->graph = fork;
ut_a(thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));
mutex_exit(&kernel_mutex);
oldtm = ut_clock();
que_run_threads(thr);
tm = ut_clock();
printf("Wall time for commit %lu milliseconds\n", tm - oldtm);
/*-------------------------------------*/
count++;
/* btr_validate_tree(tree); */
if (count < 1) {
goto loop;
}
mem_heap_free(heap);
return(0);
}
/********************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
os_thread_id_t id[10];
ulint n1000[10];
ulint i;
ulint n5000 = 500;
ulint n2;
/* buf_debug_prints = TRUE; */
log_do_write = TRUE;
srv_boot("initfile");
os_aio_init(576, 9, 100);
fil_init(25);
buf_pool_init(POOL_SIZE, POOL_SIZE);
fsp_init();
log_init();
lock_sys_create(1024);
create_files();
init_spaces();
sess_sys_init_at_db_start();
trx_sys_create();
dict_create();
/* os_thread_sleep(500000); */
oldtm = ut_clock();
ut_rnd_set_seed(19);
test1(NULL);
/* for (i = 0; i < 2; i++) {
n1000[i] = i;
id[i] = id[i];
os_thread_create(test10mt, n1000 + i, id + i);
}
*/
i = 4;
n1000[i] = i;
id[i] = id[i];
/* os_thread_create(test10_4, n1000 + i, id + i); */
i = 5;
/* test10mt(&i);
i = 6;
test10mt(&i);
trx_purge();
printf("%lu pages purged\n", purge_sys->n_pages_handled);
dict_table_print_by_name("TS_TABLE1"); */
/* os_thread_create(test_measure_cont, &n3, id + 0); */
/* mem_print_info(); */
/* dict_table_print_by_name("TS_TABLE1"); */
log_flush_up_to(ut_dulint_zero);
os_thread_sleep(500000);
n2 = 10000;
test2_1(&n2);
/* test9A(&n2);
test9(&n2); */
/* test6(&n2); */
/* test2(&n2); */
/* test2_2(&n2); */
/* mem_print_info(); */
for (i = 0; i < 2; i++) {
n1000[i] = 1000 + 10 * i;
id[i] = id[i];
/* os_thread_create(test2mt, n1000 + i, id + i);
os_thread_create(test2_1mt, n1000 + i, id + i);
os_thread_create(test2_2mt, n1000 + i, id + i); */
}
n2 = 2000;
/* test2mt(&n2); */
/* buf_print();
ibuf_print();
rw_lock_list_print_info();
mutex_list_print_info();
dict_table_print_by_name("TS_TABLE1"); */
/* mem_print_info(); */
n2 = 1000;
/* test4_1();
test4_2();
for (i = 0; i < 2; i++) {
n1000[i] = i;
id[i] = id[i];
os_thread_create(test4mt, n1000 + i, id + i);
}
n2 = 4;
test4mt(&n2);
test4mt(&n2);
test4_2();
lock_print_info(); */
/* test7(&n2); */
/* os_thread_sleep(25000000); */
tm = ut_clock();
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,397 +0,0 @@
/************************************************************************
Test for the server
(c) 1996-1997 Innobase Oy
Created 2/16/1996 Heikki Tuuri
*************************************************************************/
#include "os0proc.h"
#include "sync0sync.h"
#include "ut0mem.h"
#include "mem0mem.h"
#include "mem0pool.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "buf0buf.h"
#include "buf0flu.h"
#include "os0file.h"
#include "os0thread.h"
#include "fil0fil.h"
#include "fsp0fsp.h"
#include "rem0rec.h"
#include "rem0cmp.h"
#include "mtr0mtr.h"
#include "log0log.h"
#include "log0recv.h"
#include "page0page.h"
#include "page0cur.h"
#include "trx0trx.h"
#include "dict0boot.h"
#include "trx0sys.h"
#include "dict0crea.h"
#include "btr0btr.h"
#include "btr0pcur.h"
#include "btr0cur.h"
#include "btr0sea.h"
#include "rem0rec.h"
#include "srv0srv.h"
#include "que0que.h"
#include "com0com.h"
#include "usr0sess.h"
#include "lock0lock.h"
#include "trx0roll.h"
#include "trx0purge.h"
#include "row0ins.h"
#include "row0sel.h"
#include "row0upd.h"
#include "row0row.h"
#include "lock0lock.h"
#include "ibuf0ibuf.h"
#include "pars0pars.h"
#include "btr0sea.h"
bool measure_cont = FALSE;
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[10];
mutex_t incs_mutex;
ulint incs;
byte rnd_buf[67000];
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
ulint i;
segment = *((ulint*)arg);
printf("Io handler thread %lu starts\n", segment);
for (i = 0;; i++) {
fil_aio_wait(segment);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/*************************************************************************
Creates or opens the log files. */
void
create_log_files(void)
/*==================*/
{
bool ret;
ulint i, k;
char name[20];
printf("--------------------------------------------------------\n");
printf("Create or open log files\n");
strcpy(name, "logfile00");
for (k = 0; k < srv_n_log_groups; k++) {
for (i = 0; i < srv_n_log_files; i++) {
name[6] = (char)((ulint)'0' + k);
name[7] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_AIO,
&ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN, OS_FILE_AIO, &ret);
ut_a(ret);
} else {
ut_a(os_file_set_size(files[i],
8192 * srv_log_file_size, 0));
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k + 100, FIL_LOG);
}
ut_a(fil_validate());
fil_node_create(name, srv_log_file_size, k + 100);
}
fil_space_create(name, k + 200, FIL_LOG);
log_group_init(k, srv_n_log_files,
srv_log_file_size * UNIV_PAGE_SIZE,
k + 100, k + 200);
}
}
/*************************************************************************
Creates the files for the file system test and inserts them to the file
system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[20];
os_thread_t thr[10];
os_thread_id_t id[10];
printf("--------------------------------------------------------\n");
printf("Create or open database files\n");
strcpy(name, "tsfile00");
for (k = 0; k < 2 * srv_n_spaces; k += 2) {
for (i = 0; i < srv_n_files; i++) {
name[6] = (char)((ulint)'0' + k);
name[7] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_NORMAL, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN, OS_FILE_NORMAL, &ret);
ut_a(ret);
} else {
ut_a(os_file_set_size(files[i],
UNIV_PAGE_SIZE * srv_file_size, 0));
/* Initialize the file contents to a random value */
/*
for (j = 0; j < srv_file_size; j++) {
for (c = 0; c < UNIV_PAGE_SIZE; c++) {
rnd_buf[c] = 0xFF;
}
os_file_write(files[i], rnd_buf,
UNIV_PAGE_SIZE * j, 0,
UNIV_PAGE_SIZE);
}
*/
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k, FIL_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, srv_file_size, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
mutex_set_level(&ios_mutex, SYNC_NO_ORDER_CHECK);
/* Create i/o-handler threads: */
for (i = 0; i < 9; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
}
/************************************************************************
Inits space header of space. */
void
init_spaces(void)
/*=============*/
{
mtr_t mtr;
mtr_start(&mtr);
fsp_header_init(0, srv_file_size * srv_n_files, &mtr);
mtr_commit(&mtr);
}
/*********************************************************************
This thread is used to measure contention of latches. */
ulint
test_measure_cont(
/*==============*/
void* arg)
{
ulint i, j, k;
ulint count[8];
ulint lcount[8];
ulint lscount;
ulint lkcount;
ulint pcount, kcount, scount;
UT_NOT_USED(arg);
printf("Starting contention measurement\n");
for (i = 0; i < 1000; i++) {
for (k = 0; k < 8; k++) {
count[k] = 0;
lcount[k] = 0;
}
pcount = 0;
kcount = 0;
scount = 0;
lscount = 0;
lkcount = 0;
for (j = 0; j < 100; j++) {
if (srv_measure_by_spin) {
ut_delay(ut_rnd_interval(0, 20000));
} else {
os_thread_sleep(20000);
}
if (kernel_mutex.lock_word) {
kcount++;
}
if (lock_kernel_reserved) {
lkcount++;
}
if (buf_pool->mutex.lock_word) {
pcount++;
}
if (btr_search_mutex.lock_word) {
scount++;
}
for (k = 0; k < 8; k++) {
if (btr_search_sys->
hash_index->mutexes[k].lock_word) {
count[k]++;
}
}
for (k = 0; k < 2; k++) {
if (lock_sys->rec_hash->mutexes[k].lock_word) {
lcount[k]++;
}
}
if (kernel_mutex.lock_word
|| lock_sys->rec_hash->mutexes[0].lock_word
|| lock_sys->rec_hash->mutexes[1].lock_word) {
lscount++;
}
}
printf(
"Mutex res. p %lu, k %lu %lu, %lu %lu %lu s %lu, %lu %lu %lu %lu %lu %lu %lu %lu of %lu\n",
pcount, kcount, lkcount, lcount[0], lcount[1], lscount, scount,
count[0], count[1], count[2], count[3],
count[4], count[5], count[6], count[7], j);
sync_print_wait_info();
printf("N log i/os %lu, n non sea %lu, n sea succ %lu\n",
log_sys->n_log_ios, btr_cur_n_non_sea,
btr_search_n_succ);
}
return(0);
}
/********************************************************************
Main test function. */
void
main(void)
/*======*/
{
os_thread_id_t thread_id;
log_do_write = TRUE;
/* yydebug = TRUE; */
srv_boot("srv_init");
os_aio_init(576, 9, 100);
fil_init(25);
buf_pool_init(srv_pool_size, srv_pool_size);
fsp_init();
log_init();
lock_sys_create(srv_lock_table_size);
create_files();
create_log_files();
init_spaces();
sess_sys_init_at_db_start();
trx_sys_create();
dict_create();
log_make_checkpoint_at(ut_dulint_max);
if (srv_measure_contention) {
os_thread_create(&test_measure_cont, NULL, &thread_id);
}
if (!srv_log_archive_on) {
ut_a(DB_SUCCESS == log_archive_noarchivelog());
}
srv_master_thread();
printf("TESTS COMPLETED SUCCESSFULLY!\n");
os_process_exit(0);
}

View File

@ -1,535 +0,0 @@
/************************************************************************
Test for the server
(c) 1996-1997 Innobase Oy
Created 2/16/1996 Heikki Tuuri
*************************************************************************/
#include "os0proc.h"
#include "sync0sync.h"
#include "ut0mem.h"
#include "mem0mem.h"
#include "mem0pool.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "buf0buf.h"
#include "buf0flu.h"
#include "os0file.h"
#include "os0thread.h"
#include "fil0fil.h"
#include "fsp0fsp.h"
#include "rem0rec.h"
#include "rem0cmp.h"
#include "mtr0mtr.h"
#include "log0log.h"
#include "log0recv.h"
#include "page0page.h"
#include "page0cur.h"
#include "trx0trx.h"
#include "dict0boot.h"
#include "trx0sys.h"
#include "dict0crea.h"
#include "btr0btr.h"
#include "btr0pcur.h"
#include "btr0cur.h"
#include "btr0sea.h"
#include "rem0rec.h"
#include "srv0srv.h"
#include "que0que.h"
#include "com0com.h"
#include "usr0sess.h"
#include "lock0lock.h"
#include "trx0roll.h"
#include "trx0purge.h"
#include "row0ins.h"
#include "row0sel.h"
#include "row0upd.h"
#include "row0row.h"
#include "lock0lock.h"
#include "ibuf0ibuf.h"
#include "pars0pars.h"
#include "btr0sea.h"
bool measure_cont = FALSE;
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[10];
mutex_t incs_mutex;
ulint incs;
byte rnd_buf[67000];
ulint glob_var1 = 0;
ulint glob_var2 = 0;
mutex_t mutex2;
mutex_t test_mutex1;
mutex_t test_mutex2;
mutex_t* volatile mutexes;
bool always_false = FALSE;
ulint* test_array;
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
ulint i;
segment = *((ulint*)arg);
printf("Io handler thread %lu starts\n", segment);
for (i = 0;; i++) {
fil_aio_wait(segment);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/*************************************************************************
Creates or opens the log files. */
void
create_log_files(void)
/*==================*/
{
bool ret;
ulint i, k;
char name[20];
printf("--------------------------------------------------------\n");
printf("Create or open log files\n");
strcpy(name, "logfile00");
for (k = 0; k < srv_n_log_groups; k++) {
for (i = 0; i < srv_n_log_files; i++) {
name[6] = (char)((ulint)'0' + k);
name[7] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE, OS_FILE_AIO,
&ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN, OS_FILE_AIO, &ret);
ut_a(ret);
} else {
ut_a(os_file_set_size(files[i],
8192 * srv_log_file_size, 0));
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k + 100, FIL_LOG);
}
ut_a(fil_validate());
fil_node_create(name, srv_log_file_size, k + 100);
}
fil_space_create(name, k + 200, FIL_LOG);
log_group_init(k, srv_n_log_files,
srv_log_file_size * UNIV_PAGE_SIZE,
k + 100, k + 200);
}
}
/*************************************************************************
Creates the files for the file system test and inserts them to the file
system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[20];
os_thread_t thr[10];
os_thread_id_t id[10];
printf("--------------------------------------------------------\n");
printf("Create or open database files\n");
strcpy(name, "tsfile00");
for (k = 0; k < 2 * srv_n_spaces; k += 2) {
for (i = 0; i < srv_n_files; i++) {
name[6] = (char)((ulint)'0' + k);
name[7] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_NORMAL, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN, OS_FILE_NORMAL, &ret);
ut_a(ret);
} else {
ut_a(os_file_set_size(files[i],
UNIV_PAGE_SIZE * srv_file_size, 0));
/* Initialize the file contents to a random value */
/*
for (j = 0; j < srv_file_size; j++) {
for (c = 0; c < UNIV_PAGE_SIZE; c++) {
rnd_buf[c] = 0xFF;
}
os_file_write(files[i], rnd_buf,
UNIV_PAGE_SIZE * j, 0,
UNIV_PAGE_SIZE);
}
*/
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k, FIL_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, srv_file_size, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
mutex_set_level(&ios_mutex, SYNC_NO_ORDER_CHECK);
/* Create i/o-handler threads: */
for (i = 0; i < 9; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
}
/************************************************************************
Inits space header of space. */
void
init_spaces(void)
/*=============*/
{
mtr_t mtr;
mtr_start(&mtr);
fsp_header_init(0, srv_file_size * srv_n_files, &mtr);
mtr_commit(&mtr);
}
/*********************************************************************
This thread is used to measure contention of latches. */
ulint
test_measure_cont(
/*==============*/
void* arg)
{
ulint i, j;
ulint pcount, kcount, s_scount, s_xcount, s_mcount, lcount;
ulint t1count;
ulint t2count;
UT_NOT_USED(arg);
printf("Starting contention measurement\n");
for (i = 0; i < 1000; i++) {
pcount = 0;
kcount = 0;
s_scount = 0;
s_xcount = 0;
s_mcount = 0;
lcount = 0;
t1count = 0;
t2count = 0;
for (j = 0; j < 100; j++) {
if (srv_measure_by_spin) {
ut_delay(ut_rnd_interval(0, 20000));
} else {
os_thread_sleep(20000);
}
if (kernel_mutex.lock_word) {
kcount++;
}
if (buf_pool->mutex.lock_word) {
pcount++;
}
if (log_sys->mutex.lock_word) {
lcount++;
}
if (btr_search_latch.reader_count) {
s_scount++;
}
if (btr_search_latch.writer != RW_LOCK_NOT_LOCKED) {
s_xcount++;
}
if (btr_search_latch.mutex.lock_word) {
s_mcount++;
}
if (test_mutex1.lock_word) {
t1count++;
}
if (test_mutex2.lock_word) {
t2count++;
}
}
printf(
"Mutex res. l %lu, p %lu, k %lu s x %lu s s %lu s mut %lu of %lu\n",
lcount, pcount, kcount, s_xcount, s_scount, s_mcount, j);
sync_print_wait_info();
printf(
"log i/o %lu n non sea %lu n succ %lu n h fail %lu\n",
log_sys->n_log_ios, btr_cur_n_non_sea,
btr_search_n_succ, btr_search_n_hash_fail);
}
return(0);
}
/*********************************************************************
This thread is used to test contention of latches. */
ulint
test_sync(
/*======*/
void* arg)
{
ulint tm, oldtm;
ulint i, j;
ulint sum;
ulint rnd = ut_rnd_gen_ulint();
ulint mut_ind;
byte* ptr;
UT_NOT_USED(arg);
printf("Starting mutex reservation test\n");
oldtm = ut_clock();
sum = 0;
rnd = 87354941;
for (i = 0; i < srv_test_n_loops; i++) {
for (j = 0; j < srv_test_n_free_rnds; j++) {
rnd += 423087123;
sum += test_array[rnd % (256 * srv_test_array_size)];
}
rnd += 43605677;
mut_ind = rnd % srv_test_n_mutexes;
mutex_enter(mutexes + mut_ind);
for (j = 0; j < srv_test_n_reserved_rnds; j++) {
rnd += 423087121;
sum += test_array[rnd % (256 * srv_test_array_size)];
}
mutex_exit(mutexes + mut_ind);
if (srv_test_cache_evict) {
ptr = (byte*)(mutexes + mut_ind);
for (j = 0; j < 4; j++) {
ptr += 256 * 1024;
sum += *((ulint*)ptr);
}
}
}
if (always_false) {
printf("%lu", sum);
}
tm = ut_clock();
printf("Wall time for res. test %lu milliseconds\n", tm - oldtm);
return(0);
}
/********************************************************************
Main test function. */
void
main(void)
/*======*/
{
os_thread_id_t thread_ids[1000];
ulint tm, oldtm;
ulint rnd;
ulint i, sum;
byte* ptr;
/* mutex_t mutex; */
log_do_write = TRUE;
/* yydebug = TRUE; */
srv_boot("srv_init");
os_aio_init(576, 9, 100);
fil_init(25);
buf_pool_init(srv_pool_size, srv_pool_size);
fsp_init();
log_init();
lock_sys_create(srv_lock_table_size);
create_files();
create_log_files();
init_spaces();
sess_sys_init_at_db_start();
trx_sys_create();
dict_create();
log_make_checkpoint_at(ut_dulint_max);
printf("Hotspot semaphore addresses k %lx, p %lx, l %lx, s %lx\n",
&kernel_mutex, &(buf_pool->mutex),
&(log_sys->mutex), &btr_search_latch);
if (srv_measure_contention) {
os_thread_create(&test_measure_cont, NULL, thread_ids + 999);
}
if (!srv_log_archive_on) {
ut_a(DB_SUCCESS == log_archive_noarchivelog());
}
/*
mutex_create(&mutex);
oldtm = ut_clock();
for (i = 0; i < 2000000; i++) {
mutex_enter(&mutex);
mutex_exit(&mutex);
}
tm = ut_clock();
printf("Wall clock time for %lu mutex enter %lu milliseconds\n",
i, tm - oldtm);
*/
if (srv_test_sync) {
if (srv_test_nocache) {
mutexes = os_mem_alloc_nocache(srv_test_n_mutexes
* sizeof(mutex_t));
} else {
mutexes = mem_alloc(srv_test_n_mutexes
* sizeof(mutex_t));
}
sum = 0;
rnd = 492314896;
oldtm = ut_clock();
for (i = 0; i < 4000000; i++) {
rnd += 85967944;
ptr = ((byte*)(mutexes)) + (rnd % (srv_test_n_mutexes
* sizeof(mutex_t)));
sum += *((ulint*)ptr);
}
tm = ut_clock();
printf(
"Wall clock time for %lu random access %lu milliseconds\n",
i, tm - oldtm);
if (always_false) {
printf("%lu", sum);
}
test_array = mem_alloc(4 * 256 * srv_test_array_size);
for (i = 0; i < srv_test_n_mutexes; i++) {
mutex_create(mutexes + i);
}
for (i = 0; i < srv_test_n_threads; i++) {
os_thread_create(&test_sync, NULL, thread_ids + i);
}
}
srv_master_thread(NULL);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
os_process_exit(0);
}

View File

@ -901,13 +901,13 @@ loop:
buf_read_page(space, offset); buf_read_page(space, offset);
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
buf_dbg_counter++; buf_dbg_counter++;
if (buf_dbg_counter % 37 == 0) { if (buf_dbg_counter % 37 == 0) {
ut_ad(buf_validate()); ut_ad(buf_validate());
} }
#endif #endif
goto loop; goto loop;
} }

View File

@ -1,20 +0,0 @@
include ..\..\makefile.i
doall: tsbuf
tsbuf: ..\buf.lib tsbuf.c
$(CCOM) $(CFL) -I.. -I..\.. ..\buf.lib ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsbuf.c $(LFL)
tsos: ..\buf.lib tsos.c
$(CCOM) $(CFL) -I.. -I..\.. ..\buf.lib ..\..\mach.lib ..\..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsos.c $(LFL)

View File

@ -1,885 +0,0 @@
/************************************************************************
The test module for the file system and buffer manager
(c) 1995 Innobase Oy
Created 11/16/1995 Heikki Tuuri
*************************************************************************/
#include "string.h"
#include "os0thread.h"
#include "os0file.h"
#include "ut0ut.h"
#include "ut0byte.h"
#include "sync0sync.h"
#include "mem0mem.h"
#include "fil0fil.h"
#include "mtr0mtr.h"
#include "mtr0log.h"
#include "log0log.h"
#include "mach0data.h"
#include "..\buf0buf.h"
#include "..\buf0flu.h"
#include "..\buf0lru.h"
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[10];
mutex_t incs_mutex;
ulint incs;
#define N_SPACES 1
#define N_FILES 1
#define FILE_SIZE 4000
#define POOL_SIZE 1000
#define COUNTER_OFFSET 1500
#define LOOP_SIZE 150
#define N_THREADS 5
ulint zero = 0;
buf_frame_t* bl_arr[POOL_SIZE];
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Io handler thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = fil_aio_wait(segment, &mess);
ut_a(ret);
buf_page_io_complete((buf_block_t*)mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/*************************************************************************
This thread reports the status of sync system. */
ulint
info_thread(
/*========*/
void* arg)
{
ulint segment;
segment = *((ulint*)arg);
for (;;) {
sync_print();
os_aio_print();
printf("Debug stop threads == %lu\n", ut_dbg_stop_threads);
os_thread_sleep(30000000);
}
return(0);
}
/*************************************************************************
Creates the files for the file system test and inserts them to
the file system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[20];
os_thread_t thr[5];
os_thread_id_t id[5];
ulint err;
printf("--------------------------------------------------------\n");
printf("Create or open database files\n");
strcpy(name, "tsfile00");
for (k = 0; k < N_SPACES; k++) {
for (i = 0; i < N_FILES; i++) {
name[9] = (char)((ulint)'0' + k);
name[10] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_TABLESPACE, &ret);
if (ret == FALSE) {
err = os_file_get_last_error();
if (err != OS_FILE_ALREADY_EXISTS) {
printf("OS error %lu in file creation\n", err);
ut_error;
}
files[i] = os_file_create(
name, OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k, OS_FILE_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, FILE_SIZE, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
/*
n[9] = 9;
os_thread_create(info_thread, n + 9, id);
*/
}
/************************************************************************
Creates the test database files. */
void
create_db(void)
/*===========*/
{
ulint i;
byte* frame;
ulint j;
ulint tm, oldtm;
mtr_t mtr;
printf("--------------------------------------------------------\n");
printf("Write database pages\n");
oldtm = ut_clock();
for (i = 0; i < N_SPACES; i++) {
for (j = 0; j < FILE_SIZE * N_FILES; j++) {
mtr_start(&mtr);
mtr_set_log_mode(&mtr, MTR_LOG_NONE);
frame = buf_page_create(i, j, &mtr);
buf_page_get(i, j, RW_X_LATCH, &mtr);
if (j > FILE_SIZE * N_FILES - 64 * 2 - 1) {
mlog_write_ulint(frame + FIL_PAGE_PREV, j - 5,
MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_NEXT, j - 7,
MLOG_4BYTES, &mtr);
} else {
mlog_write_ulint(frame + FIL_PAGE_PREV, j - 1,
MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_NEXT, j + 1,
MLOG_4BYTES, &mtr);
}
mlog_write_ulint(frame + FIL_PAGE_OFFSET, j,
MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_SPACE, i,
MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + COUNTER_OFFSET, 0,
MLOG_4BYTES, &mtr);
mtr_commit(&mtr);
}
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("--------------------------------------------------------\n");
printf("TEST 1 A. Test of page creation when page resides in buffer\n");
for (i = 0; i < N_SPACES; i++) {
for (j = FILE_SIZE * N_FILES - 200;
j < FILE_SIZE * N_FILES; j++) {
mtr_start(&mtr);
mtr_set_log_mode(&mtr, MTR_LOG_NONE);
frame = buf_page_create(i, j, &mtr);
buf_page_get(i, j, RW_X_LATCH, &mtr);
mlog_write_ulint(frame + FIL_PAGE_PREV,
j - 1, MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_NEXT,
j + 1, MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_OFFSET, j,
MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_SPACE, i,
MLOG_4BYTES, &mtr);
mtr_commit(&mtr);
}
}
printf("--------------------------------------------------------\n");
printf("TEST 1 B. Flush pages\n");
buf_flush_batch(BUF_FLUSH_LIST, POOL_SIZE / 2);
buf_validate();
printf("--------------------------------------------------------\n");
printf("TEST 1 C. Allocate POOL_SIZE blocks to flush pages\n");
buf_validate();
/* Flush the pool of dirty pages */
for (i = 0; i < POOL_SIZE; i++) {
bl_arr[i] = buf_frame_alloc();
}
buf_validate();
buf_LRU_print();
for (i = 0; i < POOL_SIZE; i++) {
buf_frame_free(bl_arr[i]);
}
buf_validate();
ut_a(buf_all_freed());
mtr_start(&mtr);
frame = buf_page_get(0, 313, RW_S_LATCH, &mtr);
#ifdef UNIV_ASYNC_IO
ut_a(buf_page_io_query(buf_block_align(frame)) == TRUE);
#endif
mtr_commit(&mtr);
}
/************************************************************************
Reads the test database files. */
void
test1(void)
/*=======*/
{
ulint i, j, k, c;
byte* frame;
ulint tm, oldtm;
mtr_t mtr;
printf("--------------------------------------------------------\n");
printf("TEST 1 D. Read linearly database files\n");
oldtm = ut_clock();
for (k = 0; k < 1; k++) {
for (i = 0; i < N_SPACES; i++) {
for (j = 0; j < N_FILES * FILE_SIZE; j++) {
mtr_start(&mtr);
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
MLOG_4BYTES, &mtr)
== j);
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
MLOG_4BYTES, &mtr)
== i);
mtr_commit(&mtr);
}
}
}
tm = ut_clock();
printf("Wall clock time for %lu pages %lu milliseconds\n",
k * i * j, tm - oldtm);
buf_validate();
printf("--------------------------------------------------------\n");
printf("TEST 1 E. Read linearly downward database files\n");
oldtm = ut_clock();
c = 0;
for (k = 0; k < 1; k++) {
for (i = 0; i < N_SPACES; i++) {
for (j = ut_min(1000, FILE_SIZE - 1); j > 0; j--) {
mtr_start(&mtr);
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
c++;
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
MLOG_4BYTES, &mtr)
== j);
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
MLOG_4BYTES, &mtr)
== i);
ut_a(buf_page_io_query(buf_block_align(frame))
== FALSE);
mtr_commit(&mtr);
}
}
}
tm = ut_clock();
printf("Wall clock time for %lu pages %lu milliseconds\n",
c, tm - oldtm);
buf_validate();
}
/************************************************************************
Reads the test database files. */
void
test2(void)
/*=======*/
{
ulint i, j, k;
byte* frame;
ulint tm, oldtm;
mtr_t mtr;
printf("--------------------------------------------------------\n");
printf("TEST 2. Read randomly database files\n");
oldtm = ut_clock();
for (k = 0; k < 100; k++) {
i = ut_rnd_gen_ulint() % N_SPACES;
j = ut_rnd_gen_ulint() % (N_FILES * FILE_SIZE);
mtr_start(&mtr);
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
MLOG_4BYTES, &mtr)
== j);
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
MLOG_4BYTES, &mtr)
== i);
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall clock time for random %lu read %lu milliseconds\n",
k, tm - oldtm);
}
/************************************************************************
Reads the test database files. */
void
test3(void)
/*=======*/
{
ulint i, j, k;
byte* frame;
ulint tm, oldtm;
ulint rnd;
mtr_t mtr;
if (FILE_SIZE < POOL_SIZE + 3050 + ut_dbg_zero) {
return;
}
printf("Flush the pool of high-offset pages\n");
/* Flush the pool of high-offset pages */
for (i = 0; i < POOL_SIZE; i++) {
mtr_start(&mtr);
frame = buf_page_get(0, i, RW_S_LATCH, &mtr);
mtr_commit(&mtr);
}
buf_validate();
printf("--------------------------------------------------------\n");
printf("TEST 3. Read randomly database pages, no read-ahead\n");
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 400; k++) {
rnd += 23477;
i = 0;
j = POOL_SIZE + 10 + rnd % 3000;
mtr_start(&mtr);
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
MLOG_4BYTES, &mtr)
== j);
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
MLOG_4BYTES, &mtr)
== i);
mtr_commit(&mtr);
}
tm = ut_clock();
printf(
"Wall clock time for %lu random no read-ahead %lu milliseconds\n",
k, tm - oldtm);
buf_validate();
printf("Flush the pool of high-offset pages\n");
/* Flush the pool of high-offset pages */
for (i = 0; i < POOL_SIZE; i++) {
mtr_start(&mtr);
frame = buf_page_get(0, i, RW_S_LATCH, &mtr);
mtr_commit(&mtr);
}
buf_validate();
printf("--------------------------------------------------------\n");
printf("TEST 3 B. Read randomly database pages, random read-ahead\n");
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 400; k++) {
rnd += 23477;
i = 0;
j = POOL_SIZE + 10 + rnd % 400;
mtr_start(&mtr);
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
MLOG_4BYTES, &mtr)
== j);
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
MLOG_4BYTES, &mtr)
== i);
mtr_commit(&mtr);
}
tm = ut_clock();
printf(
"Wall clock time for %lu random read-ahead %lu milliseconds\n",
k, tm - oldtm);
}
/************************************************************************
Tests speed of CPU algorithms. */
void
test4(void)
/*=======*/
{
ulint i, j;
ulint tm, oldtm;
mtr_t mtr;
buf_frame_t* frame;
os_thread_sleep(2000000);
printf("--------------------------------------------------------\n");
printf("TEST 4. Speed of CPU algorithms\n");
oldtm = ut_clock();
for (j = 0; j < 1000; j++) {
mtr_start(&mtr);
for (i = 0; i < 20; i++) {
frame = buf_page_get(0, i, RW_S_LATCH, &mtr);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall clock time for %lu page get-release %lu milliseconds\n",
i * j, tm - oldtm);
buf_validate();
oldtm = ut_clock();
for (i = 0; i < 10000; i++) {
frame = buf_frame_alloc();
buf_frame_free(frame);
}
tm = ut_clock();
printf("Wall clock time for %lu block alloc-free %lu milliseconds\n",
i, tm - oldtm);
ha_print_info(buf_pool->page_hash);
buf_print();
}
/************************************************************************
Tests various points of code. */
void
test5(void)
/*=======*/
{
buf_frame_t* frame;
fil_addr_t addr;
ulint space;
mtr_t mtr;
printf("--------------------------------------------------------\n");
printf("TEST 5. Various tests \n");
mtr_start(&mtr);
frame = buf_page_get(0, 313, RW_S_LATCH, &mtr);
ut_a(buf_frame_get_space_id(frame) == 0);
ut_a(buf_frame_get_page_no(frame) == 313);
ut_a(buf_frame_align(frame + UNIV_PAGE_SIZE - 1) == frame);
ut_a(buf_frame_align(frame) == frame);
ut_a(buf_block_align(frame + UNIV_PAGE_SIZE - 1) ==
buf_block_align(frame));
buf_ptr_get_fsp_addr(frame + UNIV_PAGE_SIZE - 1, &space, &addr);
ut_a(addr.page == 313)
ut_a(addr.boffset == UNIV_PAGE_SIZE - 1);
ut_a(space == 0);
mtr_commit(&mtr);
}
/************************************************************************
Random test thread function. */
ulint
random_thread(
/*===========*/
void* arg)
{
ulint n;
ulint i, j, r, t, p, sp, count;
ulint s;
buf_frame_t* arr[POOL_SIZE / N_THREADS];
buf_frame_t* frame;
mtr_t mtr;
mtr_t mtr2;
n = *((ulint*)arg);
printf("Random test thread %lu starts\n", os_thread_get_curr_id());
for (i = 0; i < 30; i++) {
t = ut_rnd_gen_ulint() % 10;
r = ut_rnd_gen_ulint() % 100;
s = ut_rnd_gen_ulint() % (POOL_SIZE / N_THREADS);
p = ut_rnd_gen_ulint();
sp = ut_rnd_gen_ulint() % N_SPACES;
if (i % 100 == 0) {
printf("Thr %lu tst %lu starts\n", os_thread_get_curr_id(), t);
}
ut_a(buf_validate());
mtr_start(&mtr);
if (t == 6) {
/* Allocate free blocks */
for (j = 0; j < s; j++) {
arr[j] = buf_frame_alloc();
ut_a(arr[j]);
}
for (j = 0; j < s; j++) {
buf_frame_free(arr[j]);
}
} else if (t == 9) {
/* buf_flush_batch(BUF_FLUSH_LIST, 30); */
} else if (t == 7) {
/* x-lock many blocks */
for (j = 0; j < s; j++) {
arr[j] = buf_page_get(sp, (p + j)
% (N_FILES * FILE_SIZE),
RW_X_LATCH,
&mtr);
ut_a(arr[j]);
if (j > 0) {
ut_a(arr[j] != arr[j - 1]);
}
}
ut_a(buf_validate());
} else if (t == 8) {
/* s-lock many blocks */
for (j = 0; j < s; j++) {
arr[j] = buf_page_get(sp, (p + j)
% (N_FILES * FILE_SIZE),
RW_S_LATCH,
&mtr);
ut_a(arr[j]);
if (j > 0) {
ut_a(arr[j] != arr[j - 1]);
}
}
} else if (t <= 2) {
for (j = 0; j < r; j++) {
/* Read pages */
mtr_start(&mtr2);
frame = buf_page_get(sp,
p % (N_FILES * FILE_SIZE),
RW_S_LATCH, &mtr2);
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
MLOG_4BYTES, &mtr2)
== p % (N_FILES * FILE_SIZE));
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
MLOG_4BYTES, &mtr2)
== sp);
mtr_commit(&mtr2);
if (t == 0) {
p++; /* upward */
} else if (t == 1) {
p--; /* downward */
} else if (t == 2) {
p = ut_rnd_gen_ulint(); /* randomly */
}
}
} else if (t <= 5) {
for (j = 0; j < r; j++) {
/* Write pages */
mtr_start(&mtr2);
frame = buf_page_get(sp, p % (N_FILES * FILE_SIZE),
RW_X_LATCH, &mtr2);
count = 1 + mtr_read_ulint(frame + COUNTER_OFFSET,
MLOG_4BYTES, &mtr2);
mutex_enter(&incs_mutex);
incs++;
mutex_exit(&incs_mutex);
mlog_write_ulint(frame + COUNTER_OFFSET, count,
MLOG_4BYTES, &mtr2);
mtr_commit(&mtr2);
if (t == 3) {
p++; /* upward */
} else if (t == 4) {
p--; /* downward */
} else if (t == 5) {
p = ut_rnd_gen_ulint(); /* randomly */
}
}
} /* if t = */
mtr_commit(&mtr);
/* printf("Thr %lu tst %lu ends ", os_thread_get_curr_id(), t); */
ut_a(buf_validate());
} /* for i */
printf("\nRandom test thread %lu exits\n", os_thread_get_curr_id());
return(0);
}
/************************************************************************
Random test thread function which reports the rw-lock list. */
ulint
rw_list_thread(
/*===========*/
void* arg)
{
ulint n;
ulint i;
n = *((ulint*)arg);
printf("\nRw list test thread %lu starts\n", os_thread_get_curr_id());
for (i = 0; i < 10; i++) {
os_thread_sleep(3000000);
rw_lock_list_print_info();
buf_validate();
}
return(0);
}
/*************************************************************************
Performs random operations on the buffer with several threads. */
void
test6(void)
/*=======*/
{
ulint i, j;
os_thread_t thr[N_THREADS + 1];
os_thread_id_t id[N_THREADS + 1];
ulint n[N_THREADS + 1];
ulint count = 0;
buf_frame_t* frame;
mtr_t mtr;
printf("--------------------------------------------------------\n");
printf("TEST 6. Random multi-thread test on the buffer \n");
incs = 0;
mutex_create(&incs_mutex);
for (i = 0; i < N_THREADS; i++) {
n[i] = i;
thr[i] = os_thread_create(random_thread, n + i, id + i);
}
/*
n[N_THREADS] = N_THREADS;
thr[N_THREADS] = os_thread_create(rw_list_thread, n + N_THREADS,
id + N_THREADS);
*/
for (i = 0; i < N_THREADS; i++) {
os_thread_wait(thr[i]);
}
/* os_thread_wait(thr[N_THREADS]); */
for (i = 0; i < N_SPACES; i++) {
for (j = 0; j < N_FILES * FILE_SIZE; j++) {
mtr_start(&mtr);
frame = buf_page_get(i, j, RW_S_LATCH, &mtr);
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET,
MLOG_4BYTES, &mtr)
== j);
ut_a(mtr_read_ulint(frame + FIL_PAGE_SPACE,
MLOG_4BYTES, &mtr)
== i);
count += mtr_read_ulint(frame + COUNTER_OFFSET,
MLOG_4BYTES, &mtr);
mtr_commit(&mtr);
}
}
printf("Count %lu incs %lu\n", count, incs);
ut_a(count == incs);
}
/************************************************************************
Frees the spaces in the file system. */
void
free_system(void)
/*=============*/
{
ulint i;
for (i = 0; i < N_SPACES; i++) {
fil_space_free(i);
}
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
/* buf_debug_prints = TRUE; */
oldtm = ut_clock();
os_aio_init(160, 5);
sync_init();
mem_init(1500000);
fil_init(26); /* Allow 25 open files at a time */
buf_pool_init(POOL_SIZE, POOL_SIZE);
log_init();
buf_validate();
ut_a(fil_validate());
create_files();
create_db();
buf_validate();
test1();
buf_validate();
test2();
buf_validate();
test3();
buf_validate();
test4();
test5();
buf_validate();
test6();
buf_validate();
buf_print();
buf_flush_batch(BUF_FLUSH_LIST, POOL_SIZE + 1);
buf_print();
buf_validate();
os_thread_sleep(1000000);
buf_print();
buf_all_freed();
free_system();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,185 +0,0 @@
/************************************************************************
The test module for the operating system interface
(c) 1995 Innobase Oy
Created 9/27/1995 Heikki Tuuri
*************************************************************************/
#include "../os0thread.h"
#include "../os0shm.h"
#include "../os0proc.h"
#include "../os0sync.h"
#include "../os0file.h"
#include "ut0ut.h"
#include "sync0sync.h"
#include "mem0mem.h"
ulint last_thr = 1;
byte global_buf[1000000];
os_file_t file;
os_file_t file2;
os_event_t gl_ready;
mutex_t ios_mutex;
ulint ios;
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = os_aio_wait(segment, &mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
ut_a(ret);
/* printf("Message for thread %lu %lu\n", segment,
(ulint)mess); */
if ((ulint)mess == 3333) {
os_event_set(gl_ready);
}
}
return(0);
}
/************************************************************************
Test of io-handler threads */
void
test4(void)
/*=======*/
{
ulint i;
bool ret;
void* buf;
ulint rnd;
ulint tm, oldtm;
os_thread_t thr[5];
os_thread_id_t id[5];
ulint n[5];
printf("-------------------------------------------\n");
printf("OS-TEST 4. Test of asynchronous file io\n");
/* Align the buffer for file io */
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
gl_ready = os_event_create(NULL);
ios = 0;
sync_init();
mem_init();
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
rnd = 0;
oldtm = ut_clock();
for (i = 0; i < 4096; i++) {
ret = os_aio_read(file, (byte*)buf + 8192 * (rnd % 100),
8192 * (rnd % 4096), 0,
8192, (void*)i);
ut_a(ret);
rnd += 1;
}
ret = os_aio_read(file, buf, 8192 * (rnd % 1024), 0, 8192,
(void*)3333);
ut_a(ret);
ut_a(!os_aio_all_slots_free());
tm = ut_clock();
printf("All ios queued! N ios: %lu\n", ios);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_event_wait(gl_ready);
tm = ut_clock();
printf("N ios: %lu\n", ios);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_thread_sleep(2000000);
printf("N ios: %lu\n", ios);
ut_a(os_aio_all_slots_free());
}
/*************************************************************************
Initializes the asyncronous io system for tests. */
void
init_aio(void)
/*==========*/
{
bool ret;
void* buf;
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
os_aio_init(160, 5);
file = os_file_create("j:\\tsfile4", OS_FILE_CREATE, OS_FILE_TABLESPACE,
&ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() == OS_FILE_ALREADY_EXISTS);
file = os_file_create("j:\\tsfile4", OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
}
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
oldtm = ut_clock();
init_aio();
test4();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,19 +0,0 @@
include ..\..\makefile.i
doall: tscom tscli
tscom: ..\com.lib tscom.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\com.lib ..\..\ut.lib ..\..\mem.lib ..\..\sync.lib ..\..\os.lib tscom.c $(LFL)
tscli: ..\com.lib tscli.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\com.lib ..\..\ut.lib ..\..\mem.lib ..\..\sync.lib ..\..\os.lib tscli.c $(LFL)

View File

@ -1,96 +0,0 @@
/************************************************************************
The test module for communication
(c) 1995 Innobase Oy
Created 9/26/1995 Heikki Tuuri
*************************************************************************/
#include "../com0com.h"
#include "../com0shm.h"
#include "ut0ut.h"
#include "mem0mem.h"
#include "os0thread.h"
#include "sync0ipm.h"
#include "sync0sync.h"
byte buf[10000];
char addr[150];
void
test1(void)
/*=======*/
{
com_endpoint_t* ep;
ulint ret;
ulint size;
ulint len;
ulint addr_len;
ulint i;
ep = com_endpoint_create(COM_SHM);
ut_a(ep);
size = 8192;
ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE,
(byte*)&size, 0);
ut_a(ret == 0);
ret = com_bind(ep, "CLI", 3);
ut_a(ret == 0);
printf("Client endpoint created!\n");
for (i = 0; i < 10000; i++) {
ret = com_sendto(ep, (byte*)"Hello from client!\n", 18, "SRV", 3);
ut_a(ret == 0);
ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len);
ut_a(ret == 0);
buf[len] = '\0';
addr[addr_len] = '\0';
/*
printf(
"Message of len %lu\n%s \nreceived from address %s of len %lu\n",
len, buf, addr, addr_len);
*/
}
ret = com_endpoint_free(ep);
ut_ad(ret == 0);
printf("Count of extra system calls in com_shm %lu\n",
com_shm_system_call_count);
printf("Count of extra system calls in ip_mutex %lu\n",
ip_mutex_system_call_count);
}
void
main(void)
/*======*/
{
ulint tm, oldtm;
sync_init();
mem_init();
oldtm = ut_clock();
test1();
ut_ad(mem_all_freed());
tm = ut_clock();
printf("Wall clock time for test %ld milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,94 +0,0 @@
/************************************************************************
The test module for communication
(c) 1995 Innobase Oy
Created 9/26/1995 Heikki Tuuri
*************************************************************************/
#include "../com0com.h"
#include "../com0shm.h"
#include "ut0ut.h"
#include "mem0mem.h"
#include "os0thread.h"
#include "sync0ipm.h"
#include "sync0sync.h"
byte buf[10000];
char addr[150];
void
test1(void)
/*=======*/
{
com_endpoint_t* ep;
ulint ret;
ulint size;
ulint len;
ulint addr_len;
ulint i;
ep = com_endpoint_create(COM_SHM);
ut_a(ep);
size = 8192;
ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE,
(byte*)&size, 0);
ut_a(ret == 0);
ret = com_bind(ep, "SRV", 3);
ut_a(ret == 0);
printf("Server endpoint created!\n");
for (i = 0; i < 50000; i++) {
ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len);
ut_a(ret == 0);
buf[len] = '\0';
addr[addr_len] = '\0';
/*
printf(
"Message of len %lu\n%s \nreceived from address %s of len %lu\n",
len, buf, addr, addr_len);
*/
ret = com_sendto(ep, (byte*)"Hello from server!\n", 18, "CLI", 3);
ut_a(ret == 0);
}
ret = com_endpoint_free(ep);
ut_ad(ret == 0);
printf("Count of extra system calls in com_shm %lu\n",
com_shm_system_call_count);
printf("Count of extra system calls in ip_mutex %lu\n",
ip_mutex_system_call_count);
}
void
main(void)
/*======*/
{
ulint tm, oldtm;
sync_init();
mem_init();
oldtm = ut_clock();
test1();
ut_ad(mem_all_freed());
tm = ut_clock();
printf("Wall clock time for test %ld milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,16 +0,0 @@
include ..\..\makefile.i
tsdict: ..\dict.lib tsdict.c
$(CCOM) $(CFL) -I.. -I..\.. ..\dict.lib ..\..\data.lib ..\..\buf.lib ..\..\mach.lib ..\..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsdict.c $(LFL)

View File

@ -1,73 +0,0 @@
/************************************************************************
The test module for the data dictionary
(c) 1996 Innobase Oy
Created 1/13/1996 Heikki Tuuri
*************************************************************************/
#include "sync0sync.h"
#include "mem0mem.h"
#include "buf0buf.h"
#include "data0type.h"
#include "..\dict0dict.h"
/************************************************************************
Basic test of data dictionary. */
void
test1(void)
/*=======*/
{
dict_table_t* table;
dict_index_t* index;
table = dict_table_create("TS_TABLE1", 3);
dict_table_add_col(table, "COL1", DATA_INT, 3, 4, 5);
dict_table_add_col(table, "COL2", DATA_INT, 3, 4, 5);
dict_table_add_col(table, "COL3", DATA_INT, 3, 4, 5);
ut_a(0 == dict_table_publish(table));
index = dict_index_create("TS_TABLE1", "IND1",
DICT_UNIQUE | DICT_CLUSTERED | DICT_MIX, 2, 1);
dict_index_add_field(index, "COL2", DICT_DESCEND);
dict_index_add_field(index, "COL1", 0);
ut_a(0 == dict_index_publish(index));
dict_table_print(table);
dict_table_free(table);
ut_a(dict_all_freed());
dict_free_all();
ut_a(dict_all_freed());
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
oldtm = ut_clock();
sync_init();
mem_init();
buf_pool_init(100, 100);
dict_init();
test1();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,12 +0,0 @@
include ..\..\makefile.i
tsdyn: ..\dyn.lib tsdyn.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\dyn.lib ..\..\mem.lib ..\..\ut.lib ..\..\mach.lib ..\..\sync.lib ..\..\os.lib tsdyn.c $(LFL)

View File

@ -1,57 +0,0 @@
/************************************************************************
The test module for dynamic array
(c) 1996 Innobase Oy
Created 2/5/1996 Heikki Tuuri
*************************************************************************/
#include "../dyn0dyn.h"
#include "sync0sync.h"
#include "mem0mem.h"
/****************************************************************
Basic test. */
void
test1(void)
/*=======*/
{
dyn_array_t dyn;
ulint i;
ulint* ulint_ptr;
printf("-------------------------------------------\n");
printf("TEST 1. Basic test\n");
dyn_array_create(&dyn);
for (i = 0; i < 1000; i++) {
ulint_ptr = dyn_array_push(&dyn, sizeof(ulint));
*ulint_ptr = i;
}
ut_a(dyn_array_get_n_elements(&dyn) == 1000);
for (i = 0; i < 1000; i++) {
ulint_ptr = dyn_array_get_nth_element(&dyn, i, sizeof(ulint));
ut_a(*ulint_ptr == i);
}
dyn_array_free(&dyn);
}
void
main(void)
{
sync_init();
mem_init();
test1();
ut_ad(sync_all_freed());
ut_ad(mem_all_freed());
printf("TEST SUCCESSFULLY COMPLETED!\n");
}

View File

@ -1,15 +0,0 @@
include ..\..\makefile.i
tsfil: ..\fil.lib tsfil.c
$(CCOM) $(CFL) -I.. -I..\.. ..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsfil.c $(LFL)

View File

@ -1,329 +0,0 @@
/************************************************************************
The test module for the file system
(c) 1995 Innobase Oy
Created 10/29/1995 Heikki Tuuri
*************************************************************************/
#include "os0thread.h"
#include "os0file.h"
#include "ut0ut.h"
#include "sync0sync.h"
#include "mem0mem.h"
#include "..\fil0fil.h"
ulint last_thr = 1;
byte global_buf[10000000];
byte global_buf2[20000];
os_file_t files[1000];
os_event_t gl_ready;
mutex_t ios_mutex;
ulint ios;
/*********************************************************************
Test for synchronous file io. */
void
test1(void)
/*=======*/
{
ulint i, j;
void* mess;
bool ret;
void* buf;
ulint rnd, rnd3;
ulint tm, oldtm;
printf("-------------------------------------------\n");
printf("FIL-TEST 1. Test of synchronous file io\n");
/* Align the buffer for file io */
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
rnd = ut_time();
rnd3 = ut_time();
rnd = rnd * 3416133;
rnd3 = rnd3 * 6576681;
oldtm = ut_clock();
for (j = 0; j < 300; j++) {
for (i = 0; i < (rnd3 % 15); i++) {
fil_read((rnd % 1000) / 100, rnd % 100, 0, 8192, buf, NULL);
ut_a(fil_validate());
ret = fil_aio_wait(0, &mess);
ut_a(ret);
ut_a(fil_validate());
ut_a(*((ulint*)buf) == rnd % 1000);
rnd += 1;
}
rnd = rnd + 3416133;
rnd3 = rnd3 + 6576681;
}
tm = ut_clock();
printf("Wall clock time for synchr. io %lu milliseconds\n",
tm - oldtm);
}
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
void* buf;
ulint i;
bool ret;
segment = *((ulint*)arg);
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
printf("Thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = fil_aio_wait(segment, &mess);
ut_a(ret);
if ((ulint)mess == 3333) {
os_event_set(gl_ready);
} else {
ut_a((ulint)mess ==
*((ulint*)((byte*)buf + 8192 * (ulint)mess)));
}
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
ut_a(ret);
/* printf("Message for thread %lu %lu\n", segment,
(ulint)mess); */
}
return(0);
}
/************************************************************************
Test of io-handler threads */
void
test2(void)
/*=======*/
{
ulint i;
ulint j;
void* buf;
ulint rnd, rnd3;
ulint tm, oldtm;
os_thread_t thr[5];
os_thread_id_t id[5];
ulint n[5];
/* Align the buffer for file io */
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
gl_ready = os_event_create(NULL);
ios = 0;
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
printf("-------------------------------------------\n");
printf("FIL-TEST 2. Test of asynchronous file io\n");
rnd = ut_time();
rnd3 = ut_time();
rnd = rnd * 3416133;
rnd3 = rnd3 * 6576681;
oldtm = ut_clock();
for (j = 0; j < 300; j++) {
for (i = 0; i < (rnd3 % 15); i++) {
fil_read((rnd % 1000) / 100, rnd % 100, 0, 8192,
(void*)((byte*)buf + 8192 * (rnd % 1000)),
(void*)(rnd % 1000));
rnd += 1;
}
ut_a(fil_validate());
rnd = rnd + 3416133;
rnd3 = rnd3 + 6576681;
}
ut_a(!os_aio_all_slots_free());
tm = ut_clock();
printf("Wall clock time for asynchr. io %lu milliseconds\n",
tm - oldtm);
fil_read(5, 25, 0, 8192,
(void*)((byte*)buf + 8192 * 1000),
(void*)3333);
tm = ut_clock();
ut_a(fil_validate());
printf("All ios queued! N ios: %lu\n", ios);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_event_wait(gl_ready);
tm = ut_clock();
printf("N ios: %lu\n", ios);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_thread_sleep(2000000);
printf("N ios: %lu\n", ios);
ut_a(fil_validate());
ut_a(os_aio_all_slots_free());
}
/*************************************************************************
Creates the files for the file system test and inserts them to
the file system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, j, k, n;
void* buf;
void* mess;
char name[10];
buf = (void*)(((ulint)global_buf2 + 6300) & (~0xFFF));
name[0] = 't';
name[1] = 's';
name[2] = 'f';
name[3] = 'i';
name[4] = 'l';
name[5] = 'e';
name[8] = '\0';
for (k = 0; k < 10; k++) {
for (i = 0; i < 20; i++) {
name[6] = (char)(k + (ulint)'a');
name[7] = (char)(i + (ulint)'a');
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_TABLESPACE, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(name, OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
} else {
for (j = 0; j < 5; j++) {
for (n = 0; n < 8192 / sizeof(ulint); n++) {
*((ulint*)buf + n) =
k * 100 + i * 5 + j;
}
ret = os_aio_write(files[i], buf, 8192 * j,
0, 8192, NULL);
ut_a(ret);
ret = os_aio_wait(0, &mess);
ut_a(ret);
ut_a(mess == NULL);
}
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create("noname", k, OS_FILE_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, 5, k);
}
}
}
/************************************************************************
Frees the spaces in the file system. */
void
free_system(void)
/*=============*/
{
ulint i;
for (i = 0; i < 10; i++) {
fil_space_free(i);
}
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
oldtm = ut_clock();
os_aio_init(160, 5);
sync_init();
mem_init();
fil_init(2); /* Allow only 2 open files at a time */
ut_a(fil_validate());
create_files();
test1();
test2();
free_system();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,891 +0,0 @@
/************************************************************************
The test module for the file system and buffer manager
(c) 1995 Innobase Oy
Created 11/16/1995 Heikki Tuuri
*************************************************************************/
#include "string.h"
#include "os0thread.h"
#include "os0file.h"
#include "ut0ut.h"
#include "ut0byte.h"
#include "sync0sync.h"
#include "mem0mem.h"
#include "fil0fil.h"
#include "..\buf0buf.h"
#include "..\buf0buf.h1"
#include "..\buf0buf.h2"
#include "..\buf0flu.h"
#include "..\buf0lru.h"
#include "mtr0buf.h"
#include "mtr0log.h"
#include "fsp0fsp.h"
#include "log0log.h"
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[5];
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = fil_aio_wait(segment, &mess);
ut_a(ret);
buf_page_io_complete((buf_block_t*)mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/************************************************************************
Creates the test database files. */
void
create_db(void)
/*===========*/
{
ulint i;
buf_block_t* block;
byte* frame;
ulint j;
ulint tm, oldtm;
mtr_t mtr;
oldtm = ut_clock();
for (i = 0; i < 1; i++) {
for (j = 0; j < 4096; j++) {
mtr_start(&mtr);
if (j == 0) {
fsp_header_init(i, 4096, &mtr);
block = mtr_page_get(i, j, NULL, &mtr);
} else {
block = mtr_page_create(i, j, &mtr);
}
frame = buf_block_get_frame(block);
mtr_page_x_lock(block, &mtr);
mlog_write_ulint(frame + FIL_PAGE_PREV,
j - 1, MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_NEXT,
j + 1, MLOG_4BYTES, &mtr);
mlog_write_ulint(frame + FIL_PAGE_OFFSET,
j, MLOG_4BYTES, &mtr);
mtr_commit(&mtr);
}
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
/* Flush the pool of dirty pages by reading low-offset pages */
for (i = 0; i < 1000; i++) {
mtr_start(&mtr);
block = mtr_page_get(0, i, NULL, &mtr);
frame = buf_block_get_frame(block);
mtr_page_s_lock(block, &mtr);
ut_a(mtr_read_ulint(frame + FIL_PAGE_OFFSET, MLOG_4BYTES,
&mtr) == i);
mtr_commit(&mtr);
}
os_thread_sleep(1000000);
ut_a(buf_all_freed());
}
/*************************************************************************
Creates the files for the file system test and inserts them to
the file system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[20];
os_thread_t thr[5];
os_thread_id_t id[5];
strcpy(name, "j:\\tsfile1");
for (k = 0; k < 1; k++) {
for (i = 0; i < 4; i++) {
name[9] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_TABLESPACE, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
}
ret = os_file_set_size(files[i], 4096 * 8192, 0);
ut_a(ret);
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create("noname", k, OS_FILE_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, 4096, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
}
/************************************************************************
Reads the test database files. */
void
test1(void)
/*=======*/
{
ulint i, j, k;
buf_block_t* block;
byte* frame;
ulint tm, oldtm;
buf_flush_batch(BUF_FLUSH_LIST, 1000);
os_thread_sleep(1000000);
buf_all_freed();
oldtm = ut_clock();
for (k = 0; k < 1; k++) {
for (i = 0; i < 1; i++) {
for (j = 0; j < 409; j++) {
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
buf_page_s_lock(block);
ut_a(*((ulint*)(frame + 16)) == j);
buf_page_s_unlock(block);
buf_page_release(block);
}
}
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
}
/************************************************************************
Reads the test database files. */
void
test2(void)
/*=======*/
{
ulint i, j, k, rnd;
buf_block_t* block;
byte* frame;
ulint tm, oldtm;
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 100; k++) {
rnd += 23651;
rnd = rnd % 4096;
i = rnd / 4096;
j = rnd % 2048;
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
buf_page_s_lock(block);
ut_a(*((ulint*)(frame + 16)) == j);
buf_page_s_unlock(block);
buf_page_release(block);
}
tm = ut_clock();
printf("Wall clock time for random read %lu milliseconds\n",
tm - oldtm);
}
/************************************************************************
Reads the test database files. */
void
test4(void)
/*=======*/
{
ulint i, j, k, rnd;
buf_block_t* block;
byte* frame;
ulint tm, oldtm;
/* Flush the pool of high-offset pages */
for (i = 0; i < 1000; i++) {
block = buf_page_get(0, i, NULL);
frame = buf_block_get_frame(block);
buf_page_s_lock(block);
ut_a(*((ulint*)(frame + 16)) == i);
buf_page_s_unlock(block);
buf_page_release(block);
}
printf("Test starts\n");
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 400; k++) {
rnd += 4357;
i = 0;
j = 1001 + rnd % 3000;
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
buf_page_s_lock(block);
ut_a(*((ulint*)(frame + 16)) == j);
buf_page_s_unlock(block);
buf_page_release(block);
}
tm = ut_clock();
printf(
"Wall clock time for %lu random no read-ahead %lu milliseconds\n",
k, tm - oldtm);
/* Flush the pool of high-offset pages */
for (i = 0; i < 1000; i++) {
block = buf_page_get(0, i, NULL);
frame = buf_block_get_frame(block);
buf_page_s_lock(block);
ut_a(*((ulint*)(frame + 16)) == i);
buf_page_s_unlock(block);
buf_page_release(block);
}
printf("Test starts\n");
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 400; k++) {
rnd += 4357;
i = 0;
j = 1001 + rnd % 400;
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
buf_page_s_lock(block);
ut_a(*((ulint*)(frame + 16)) == j);
buf_page_s_unlock(block);
buf_page_release(block);
}
tm = ut_clock();
printf(
"Wall clock time for %lu random read-ahead %lu milliseconds\n",
k, tm - oldtm);
}
/************************************************************************
Tests speed of CPU algorithms. */
void
test3(void)
/*=======*/
{
ulint i, j;
buf_block_t* block;
ulint tm, oldtm;
for (i = 0; i < 400; i++) {
block = buf_page_get(0, i, NULL);
buf_page_release(block);
}
os_thread_sleep(2000000);
oldtm = ut_clock();
for (j = 0; j < 500; j++) {
for (i = 0; i < 200; i++) {
block = buf_page_get(0, i, NULL);
/*
buf_page_s_lock(block);
buf_page_s_unlock(block);
*/
buf_page_release(block);
}
}
tm = ut_clock();
printf("Wall clock time for %lu page get-release %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (j = 0; j < 500; j++) {
for (i = 0; i < 200; i++) {
buf_page_get(0, i, NULL);
/*
buf_page_s_lock(block);
buf_page_s_unlock(block);
*/
buf_page_release(block);
}
}
tm = ut_clock();
printf("Wall clock time for %lu block get-release %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 100000; i++) {
block = buf_block_alloc();
buf_block_free(block);
}
tm = ut_clock();
printf("Wall clock time for %lu block alloc-free %lu milliseconds\n",
i, tm - oldtm);
ha_print_info(buf_pool->page_hash);
}
/************************************************************************
Frees the spaces in the file system. */
void
free_system(void)
/*=============*/
{
ulint i;
for (i = 0; i < 1; i++) {
fil_space_free(i);
}
}
/************************************************************************
Test for file space management. */
void
test5(void)
/*=======*/
{
mtr_t mtr;
ulint seg_page;
ulint new_page;
ulint seg_page2;
ulint new_page2;
buf_block_t* block;
bool finished;
ulint i;
ulint reserved;
ulint used;
ulint tm, oldtm;
os_thread_sleep(1000000);
buf_validate();
buf_print();
mtr_start(&mtr);
seg_page = fseg_create(0, 0, 1000, 555, &mtr);
mtr_commit(&mtr);
os_thread_sleep(1000000);
buf_validate();
printf("Segment created: header page %lu\n", seg_page);
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
new_page = fseg_alloc_free_page(buf_block_get_frame(block) + 1000,
2, FSP_UP, &mtr);
mtr_commit(&mtr);
buf_validate();
buf_print();
printf("Segment page allocated %lu\n", new_page);
finished = FALSE;
while (!finished) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
finished = fseg_free_step(
buf_block_get_frame(block) + 1000, &mtr);
mtr_commit(&mtr);
}
/***********************************************/
os_thread_sleep(1000000);
buf_validate();
buf_print();
mtr_start(&mtr);
seg_page = fseg_create(0, 0, 1000, 557, &mtr);
mtr_commit(&mtr);
ut_a(seg_page == 1);
printf("Segment created: header page %lu\n", seg_page);
new_page = seg_page;
for (i = 0; i < 1023; i++) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
new_page = fseg_alloc_free_page(
buf_block_get_frame(block) + 1000,
new_page + 1, FSP_UP, &mtr);
if (i < FSP_EXTENT_SIZE - 1) {
ut_a(new_page == 2 + i);
} else {
ut_a(new_page == i + FSP_EXTENT_SIZE + 1);
}
printf("%lu %lu; ", i, new_page);
if (i % 10 == 0) {
printf("\n");
}
mtr_commit(&mtr);
}
buf_print();
buf_validate();
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
mtr_page_s_lock(block, &mtr);
reserved = fseg_n_reserved_pages(buf_block_get_frame(block) + 1000,
&used, &mtr);
ut_a(used == 1024);
ut_a(reserved >= 1024);
printf("Pages used in segment %lu reserved by segment %lu \n",
used, reserved);
mtr_commit(&mtr);
finished = FALSE;
while (!finished) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
finished = fseg_free_step(
buf_block_get_frame(block) + 1000, &mtr);
mtr_commit(&mtr);
}
buf_print();
buf_validate();
/***********************************************/
mtr_start(&mtr);
seg_page = fseg_create(0, 0, 1000, 557, &mtr);
mtr_commit(&mtr);
ut_a(seg_page == 1);
mtr_start(&mtr);
seg_page2 = fseg_create(0, 0, 1000, 558, &mtr);
mtr_commit(&mtr);
ut_a(seg_page2 == 2);
new_page = seg_page;
new_page2 = seg_page2;
for (;;) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
new_page = fseg_alloc_free_page(
buf_block_get_frame(block) + 1000,
new_page + 1, FSP_UP, &mtr);
printf("1:%lu %lu; ", i, new_page);
if (i % 10 == 0) {
printf("\n");
}
new_page = fseg_alloc_free_page(
buf_block_get_frame(block) + 1000,
new_page + 1, FSP_UP, &mtr);
printf("1:%lu %lu; ", i, new_page);
if (i % 10 == 0) {
printf("\n");
}
mtr_commit(&mtr);
mtr_start(&mtr);
block = mtr_page_get(0, seg_page2, NULL, &mtr);
new_page2 = fseg_alloc_free_page(
buf_block_get_frame(block) + 1000,
new_page2 + 1, FSP_UP, &mtr);
printf("2:%lu %lu; ", i, new_page2);
if (i % 10 == 0) {
printf("\n");
}
mtr_commit(&mtr);
if (new_page2 == FIL_NULL) {
break;
}
}
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
mtr_page_s_lock(block, &mtr);
reserved = fseg_n_reserved_pages(buf_block_get_frame(block) + 1000,
&used, &mtr);
printf("Pages used in segment 1 %lu, reserved by segment %lu \n",
used, reserved);
mtr_commit(&mtr);
mtr_start(&mtr);
block = mtr_page_get(0, seg_page2, NULL, &mtr);
mtr_page_s_lock(block, &mtr);
reserved = fseg_n_reserved_pages(buf_block_get_frame(block) + 1000,
&used, &mtr);
printf("Pages used in segment 2 %lu, reserved by segment %lu \n",
used, reserved);
mtr_commit(&mtr);
for (;;) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
fseg_free_step(
buf_block_get_frame(block) + 1000, &mtr);
block = mtr_page_get(0, seg_page2, NULL, &mtr);
finished = fseg_free_step(
buf_block_get_frame(block) + 1000, &mtr);
mtr_commit(&mtr);
if (finished) {
break;
}
}
mtr_start(&mtr);
seg_page2 = fseg_create(0, 0, 1000, 558, &mtr);
mtr_commit(&mtr);
i = 0;
for (;;) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page2, NULL, &mtr);
new_page2 = fseg_alloc_free_page(
buf_block_get_frame(block) + 1000,
557, FSP_DOWN, &mtr);
printf("%lu %lu; ", i, new_page2);
mtr_commit(&mtr);
if (new_page2 == FIL_NULL) {
break;
}
i++;
}
for (;;) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
finished = fseg_free_step(
buf_block_get_frame(block) + 1000, &mtr);
mtr_commit(&mtr);
if (finished) {
break;
}
}
for (;;) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page2, NULL, &mtr);
finished = fseg_free_step(
buf_block_get_frame(block) + 1000, &mtr);
mtr_commit(&mtr);
if (finished) {
break;
}
}
/***************************************/
oldtm = ut_clock();
for (i = 0; i < 1000; i++) {
mtr_start(&mtr);
seg_page = fseg_create(0, 0, 1000, 555, &mtr);
mtr_commit(&mtr);
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
new_page = fseg_alloc_free_page(buf_block_get_frame(block) + 1000,
2, FSP_UP, &mtr);
mtr_commit(&mtr);
finished = FALSE;
while (!finished) {
mtr_start(&mtr);
block = mtr_page_get(0, seg_page, NULL, &mtr);
finished = fseg_free_step(
buf_block_get_frame(block) + 1000, &mtr);
mtr_commit(&mtr);
}
}
tm = ut_clock();
printf("Wall clock time for %lu seg crea+free %lu millisecs\n",
i, tm - oldtm);
buf_validate();
buf_flush_batch(BUF_FLUSH_LIST, 500);
os_thread_sleep(1000000);
buf_all_freed();
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
ulint n;
oldtm = ut_clock();
os_aio_init(160, 5);
sync_init();
mem_init();
fil_init(26); /* Allow 25 open files at a time */
buf_pool_init(1000, 1000);
log_init();
buf_validate();
ut_a(fil_validate());
create_files();
create_db();
buf_validate();
test5();
/*
test1();
test3();
test4();
test2();
*/
buf_validate();
n = buf_flush_batch(BUF_FLUSH_LIST, 500);
os_thread_sleep(1000000);
buf_all_freed();
free_system();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,16 +0,0 @@
include ..\..\makefile.i
tsfsp: ..\fsp.lib tsfsp.c
$(CCOM) $(CFL) -I.. -I..\.. ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsfsp.c $(LFL)

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +0,0 @@
include ..\..\makefile.i
tsha: ..\ha.lib tsha.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsha.c $(LFL)

View File

@ -1,120 +0,0 @@
/************************************************************************
The test module for hash table
(c) 1994, 1995 Innobase Oy
Created 1/25/1994 Heikki Tuuri
*************************************************************************/
#include "ut0ut.h"
#include "ha0ha.h"
#include "mem0mem.h"
#include "sync0sync.h"
ulint ulint_array[200000];
void
test1(void)
{
hash_table_t* table1;
ulint i;
ulint n313 = 313;
ulint n414 = 414;
printf("------------------------------------------------\n");
printf("TEST 1. BASIC TEST\n");
table1 = ha_create(50000);
ha_insert_for_fold(table1, 313, &n313);
ha_insert_for_fold(table1, 313, &n414);
ut_a(ha_validate(table1));
ha_delete(table1, 313, &n313);
ha_delete(table1, 313, &n414);
ut_a(ha_validate(table1));
printf("------------------------------------------------\n");
printf("TEST 2. TEST OF MASSIVE INSERTS AND DELETES\n");
table1 = ha_create(10000);
for (i = 0; i < 200000; i++) {
ulint_array[i] = i;
}
for (i = 0; i < 50000; i++) {
ha_insert_for_fold(table1, i * 7, ulint_array + i);
}
ut_a(ha_validate(table1));
for (i = 0; i < 50000; i++) {
ha_delete(table1, i * 7, ulint_array + i);
}
ut_a(ha_validate(table1));
}
void
test2(void)
{
hash_table_t* table1;
ulint i;
ulint oldtm, tm;
ha_node_t* node;
printf("------------------------------------------------\n");
printf("TEST 3. SPEED TEST\n");
table1 = ha_create(300000);
oldtm = ut_clock();
for (i = 0; i < 200000; i++) {
ha_insert_for_fold(table1, i * 27877, ulint_array + i);
}
tm = ut_clock();
printf("Wall clock time for %lu inserts %lu millisecs\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 200000; i++) {
node = ha_search(table1, i * 27877);
}
tm = ut_clock();
printf("Wall clock time for %lu searches %lu millisecs\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 200000; i++) {
ha_delete(table1, i * 27877, ulint_array + i);
}
tm = ut_clock();
printf("Wall clock time for %lu deletes %lu millisecs\n",
i, tm - oldtm);
}
void
main(void)
{
sync_init();
mem_init(1000000);
test1();
test2();
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -50,7 +50,7 @@ noinst_HEADERS = btr0btr.h btr0btr.ic btr0cur.h btr0cur.ic \
thr0loc.h thr0loc.ic trx0purge.h trx0purge.ic trx0rec.h \ thr0loc.h thr0loc.ic trx0purge.h trx0purge.ic trx0rec.h \
trx0rec.ic trx0roll.h trx0roll.ic trx0rseg.h trx0rseg.ic \ trx0rec.ic trx0roll.h trx0roll.ic trx0rseg.h trx0rseg.ic \
trx0sys.h trx0sys.ic trx0trx.h trx0trx.ic trx0types.h \ trx0sys.h trx0sys.ic trx0trx.h trx0trx.ic trx0types.h \
trx0undo.h trx0undo.ic univ.i univold.i univoldmysql.i \ trx0undo.h trx0undo.ic univ.i \
usr0sess.h usr0sess.ic usr0types.h ut0byte.h ut0byte.ic \ usr0sess.h usr0sess.ic usr0types.h ut0byte.h ut0byte.ic \
ut0dbg.h ut0lst.h ut0mem.h ut0mem.ic ut0rnd.h ut0rnd.ic \ ut0dbg.h ut0lst.h ut0mem.h ut0mem.ic ut0rnd.h ut0rnd.ic \
ut0sort.h ut0ut.h ut0ut.ic ut0sort.h ut0ut.h ut0ut.ic

View File

@ -162,7 +162,7 @@ mem_heap_alloc(
mem_block_set_free(block, free + MEM_SPACE_NEEDED(n)); mem_block_set_free(block, free + MEM_SPACE_NEEDED(n));
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
/* In the debug version write debugging info to the field */ /* In the debug version write debugging info to the field */
mem_field_init((byte*)buf, n); mem_field_init((byte*)buf, n);
@ -171,7 +171,7 @@ mem_heap_alloc(
caller */ caller */
buf = (byte*)buf + MEM_FIELD_HEADER_SIZE; buf = (byte*)buf + MEM_FIELD_HEADER_SIZE;
#endif #endif
#ifdef UNIV_SET_MEM_TO_ZERO #ifdef UNIV_SET_MEM_TO_ZERO
memset(buf, '\0', n); memset(buf, '\0', n);
#endif #endif
@ -212,15 +212,15 @@ mem_heap_free_heap_top(
{ {
mem_block_t* block; mem_block_t* block;
mem_block_t* prev_block; mem_block_t* prev_block;
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
ibool error; ibool error;
ulint total_size; ulint total_size;
ulint size; ulint size;
#endif #endif
ut_ad(mem_heap_check(heap)); ut_ad(mem_heap_check(heap));
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
/* Validate the heap and get its total allocated size */ /* Validate the heap and get its total allocated size */
mem_heap_validate_or_print(heap, NULL, FALSE, &error, &total_size, mem_heap_validate_or_print(heap, NULL, FALSE, &error, &total_size,
@ -232,7 +232,7 @@ mem_heap_free_heap_top(
NULL); NULL);
ut_a(!error); ut_a(!error);
#endif #endif
block = UT_LIST_GET_LAST(heap->base); block = UT_LIST_GET_LAST(heap->base);
@ -259,7 +259,7 @@ mem_heap_free_heap_top(
/* Set the free field of block */ /* Set the free field of block */
mem_block_set_free(block, old_top - (byte*)block); mem_block_set_free(block, old_top - (byte*)block);
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
ut_ad(mem_block_get_start(block) <= mem_block_get_free(block)); ut_ad(mem_block_get_start(block) <= mem_block_get_free(block));
/* In the debug version erase block from top up */ /* In the debug version erase block from top up */
@ -271,7 +271,7 @@ mem_heap_free_heap_top(
mem_current_allocated_memory -= (total_size - size); mem_current_allocated_memory -= (total_size - size);
mutex_exit(&mem_hash_mutex); mutex_exit(&mem_hash_mutex);
#endif #endif
/* If free == start, we may free the block if it is not the first /* If free == start, we may free the block if it is not the first
one */ one */
@ -317,7 +317,7 @@ mem_heap_get_top(
buf = (byte*)block + mem_block_get_free(block) - MEM_SPACE_NEEDED(n); buf = (byte*)block + mem_block_get_free(block) - MEM_SPACE_NEEDED(n);
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
ut_ad(mem_block_get_start(block) <=(ulint)((byte*)buf - (byte*)block)); ut_ad(mem_block_get_start(block) <=(ulint)((byte*)buf - (byte*)block));
/* In the debug version, advance buf to point at the storage which /* In the debug version, advance buf to point at the storage which
@ -327,7 +327,7 @@ mem_heap_get_top(
/* Check that the field lengths agree */ /* Check that the field lengths agree */
ut_ad(n == (ulint)mem_field_header_get_len(buf)); ut_ad(n == (ulint)mem_field_header_get_len(buf));
#endif #endif
return(buf); return(buf);
} }
@ -351,13 +351,13 @@ mem_heap_free_top(
/* Subtract the free field of block */ /* Subtract the free field of block */
mem_block_set_free(block, mem_block_get_free(block) mem_block_set_free(block, mem_block_get_free(block)
- MEM_SPACE_NEEDED(n)); - MEM_SPACE_NEEDED(n));
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
ut_ad(mem_block_get_start(block) <= mem_block_get_free(block)); ut_ad(mem_block_get_start(block) <= mem_block_get_free(block));
/* In the debug version check the consistency, and erase field */ /* In the debug version check the consistency, and erase field */
mem_field_erase((byte*)block + mem_block_get_free(block), n); mem_field_erase((byte*)block + mem_block_get_free(block), n);
#endif #endif
/* If free == start, we may free the block if it is not the first /* If free == start, we may free the block if it is not the first
one */ one */
@ -417,7 +417,7 @@ mem_heap_create_func(
/* Add the created block itself as the first block in the list */ /* Add the created block itself as the first block in the list */
UT_LIST_ADD_FIRST(list, block->base, block); UT_LIST_ADD_FIRST(list, block->base, block);
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
if (block == NULL) { if (block == NULL) {
@ -426,7 +426,7 @@ mem_heap_create_func(
mem_hash_insert(block, file_name, line); mem_hash_insert(block, file_name, line);
#endif #endif
return(block); return(block);
} }
@ -452,14 +452,14 @@ mem_heap_free_func(
block = UT_LIST_GET_LAST(heap->base); block = UT_LIST_GET_LAST(heap->base);
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
/* In the debug version remove the heap from the hash table of heaps /* In the debug version remove the heap from the hash table of heaps
and check its consistency */ and check its consistency */
mem_hash_remove(heap, file_name, line); mem_hash_remove(heap, file_name, line);
#endif #endif
if (heap->free_block) { if (heap->free_block) {
mem_heap_free_block_free(heap); mem_heap_free_block_free(heap);

View File

@ -20,16 +20,6 @@ srv_normalize_path_for_win(
/*=======================*/ /*=======================*/
char* str); /* in/out: null-terminated character string */ char* str); /* in/out: null-terminated character string */
/************************************************************************* /*************************************************************************
Adds a slash or a backslash to the end of a string if it is missing
and the string is not empty. */
char*
srv_add_path_separator_if_needed(
/*=============================*/
/* out, own: string which has the separator if the
string is not empty */
char* str); /* in: null-terminated character string */
/*************************************************************************
Reads the data files and their sizes from a character string given in Reads the data files and their sizes from a character string given in
the .cnf file. */ the .cnf file. */

View File

@ -140,10 +140,10 @@ rw_lock_s_lock_low(
/* Set the shared lock by incrementing the reader count */ /* Set the shared lock by incrementing the reader count */
lock->reader_count++; lock->reader_count++;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name, rw_lock_add_debug_info(lock, pass, RW_LOCK_SHARED, file_name,
line); line);
#endif #endif
lock->last_s_file_name = file_name; lock->last_s_file_name = file_name;
lock->last_s_line = line; lock->last_s_line = line;
@ -175,9 +175,9 @@ rw_lock_s_lock_direct(
lock->last_s_file_name = file_name; lock->last_s_file_name = file_name;
lock->last_s_line = line; lock->last_s_line = line;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name, line); rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name, line);
#endif #endif
} }
/********************************************************************** /**********************************************************************
@ -204,9 +204,9 @@ rw_lock_x_lock_direct(
lock->last_x_file_name = file_name; lock->last_x_file_name = file_name;
lock->last_x_line = line; lock->last_x_line = line;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line); rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
#endif #endif
} }
/********************************************************************** /**********************************************************************
@ -275,10 +275,10 @@ rw_lock_s_lock_func_nowait(
/* Set the shared lock by incrementing the reader count */ /* Set the shared lock by incrementing the reader count */
lock->reader_count++; lock->reader_count++;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name, rw_lock_add_debug_info(lock, 0, RW_LOCK_SHARED, file_name,
line); line);
#endif #endif
lock->last_s_file_name = file_name; lock->last_s_file_name = file_name;
lock->last_s_line = line; lock->last_s_line = line;
@ -320,9 +320,9 @@ rw_lock_x_lock_func_nowait(
lock->writer_count++; lock->writer_count++;
lock->pass = 0; lock->pass = 0;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line); rw_lock_add_debug_info(lock, 0, RW_LOCK_EX, file_name, line);
#endif #endif
lock->last_x_file_name = file_name; lock->last_x_file_name = file_name;
lock->last_x_line = line; lock->last_x_line = line;
@ -361,9 +361,9 @@ rw_lock_s_unlock_func(
ut_a(lock->reader_count > 0); ut_a(lock->reader_count > 0);
lock->reader_count--; lock->reader_count--;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED); rw_lock_remove_debug_info(lock, pass, RW_LOCK_SHARED);
#endif #endif
/* If there may be waiters and this was the last s-lock, /* If there may be waiters and this was the last s-lock,
signal the object */ signal the object */
@ -402,9 +402,9 @@ rw_lock_s_unlock_direct(
lock->reader_count--; lock->reader_count--;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED); rw_lock_remove_debug_info(lock, 0, RW_LOCK_SHARED);
#endif #endif
ut_ad(!lock->waiters); ut_ad(!lock->waiters);
ut_ad(rw_lock_validate(lock)); ut_ad(rw_lock_validate(lock));
@ -442,9 +442,9 @@ rw_lock_x_unlock_func(
rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED); rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
} }
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX); rw_lock_remove_debug_info(lock, pass, RW_LOCK_EX);
#endif #endif
/* If there may be waiters, signal the lock */ /* If there may be waiters, signal the lock */
if (lock->waiters && (lock->writer_count == 0)) { if (lock->waiters && (lock->writer_count == 0)) {
@ -486,9 +486,9 @@ rw_lock_x_unlock_direct(
rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED); rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
} }
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX); rw_lock_remove_debug_info(lock, 0, RW_LOCK_EX);
#endif #endif
ut_ad(!lock->waiters); ut_ad(!lock->waiters);
ut_ad(rw_lock_validate(lock)); ut_ad(rw_lock_validate(lock));

View File

@ -250,9 +250,9 @@ mutex_enter_func(
if (!mutex_test_and_set(mutex)) { if (!mutex_test_and_set(mutex)) {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line); mutex_set_debug_info(mutex, file_name, line);
#endif #endif
mutex->file_name = file_name; mutex->file_name = file_name;
mutex->line = line; mutex->line = line;

View File

@ -1,164 +0,0 @@
/***************************************************************************
Version control for database, common definitions, and include files
(c) 1994 - 2000 Innobase Oy
Created 1/20/1994 Heikki Tuuri
****************************************************************************/
#ifndef univ_i
#define univ_i
#define UNIV_INTEL
#define UNIV_PENTIUM
/* If UNIV_WINNT is not defined, we assume Windows 95 */
#define UNIV_WINNT
#define UNIV_WINNT4
#define __NT__
#define UNIV_VISUALC
#define __WIN__
#define _WIN32_WINNT 0x0400
/* DEBUG VERSION CONTROL
===================== */
/* Make a non-inline debug version */
/*
#define UNIV_DEBUG
#define UNIV_MEM_DEBUG
#define UNIV_SYNC_DEBUG
#define UNIV_SEARCH_DEBUG
#define UNIV_IBUF_DEBUG
#define UNIV_SEARCH_PERF_STAT
#define UNIV_SYNC_PERF_STAT
*/
#define UNIV_LIGHT_MEM_DEBUG
#define YYDEBUG 1
/*
#define UNIV_SQL_DEBUG
#define UNIV_LOG_DEBUG
*/
/* the above option prevents forcing of log to disk
at a buffer page write: it should be tested with this
option off; also some ibuf tests are suppressed */
/*
#define UNIV_BASIC_LOG_DEBUG
*/
/* the above option enables basic recovery debugging:
new allocated file pages are reset */
/* The debug version is slower, thus we may change the length of test loops
depending on the UNIV_DBC parameter */
#ifdef UNIV_DEBUG
#define UNIV_DBC 1
#else
#define UNIV_DBC 100
#endif
#ifndef UNIV_DEBUG
/* Definition for inline version */
#ifdef UNIV_VISUALC
#define UNIV_INLINE __inline
#elif defined(UNIV_GNUC)
#define UNIV_INLINE extern __inline__
#endif
#else
/* If we want to compile a noninlined version we use the following macro
definitions: */
#define UNIV_NONINL
#define UNIV_INLINE
#endif /* UNIV_DEBUG */
/* If the compiler does not know inline specifier, we use: */
/*
#define UNIV_INLINE static
*/
/*
MACHINE VERSION CONTROL
=======================
*/
#ifdef UNIV_PENTIUM
/* In a 32-bit computer word size is 4 */
#define UNIV_WORD_SIZE 4
/* The following alignment is used in memory allocations in memory heap
management to ensure correct alignment for doubles etc. */
#define UNIV_MEM_ALIGNMENT 8
/* The following alignment is used in aligning lints etc. */
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
#endif
/*
DATABASE VERSION CONTROL
========================
*/
/* The universal page size of the database */
#define UNIV_PAGE_SIZE (2 * 8192)/* NOTE! Currently, this has to be a
power of 2 and divisible by
UNIV_MEM_ALIGNMENT */
/* Do non-buffered io in buffer pool read/write operations */
#define UNIV_NON_BUFFERED_IO
/* Maximum number of parallel threads in a parallelized operation */
#define UNIV_MAX_PARALLELISM 32
/*
UNIVERSAL TYPE DEFINITIONS
==========================
*/
typedef unsigned char byte;
/* An other basic type we use is unsigned long integer which is intended to be
equal to the word size of the machine. */
typedef unsigned long int ulint;
typedef long int lint;
/* The following type should be at least a 64-bit floating point number */
typedef double utfloat;
/* The 'undefined' value for a ulint */
#define ULINT_UNDEFINED ((ulint)(-1))
/* The undefined 32-bit unsigned integer */
#define ULINT32_UNDEFINED 0xFFFFFFFF
/* Maximum value for a ulint */
#define ULINT_MAX ((ulint)(-2))
/* Definition of the boolean type */
typedef ulint bool;
#define TRUE 1
#define FALSE 0
/* The following number as the length of a logical field means that the field
has the SQL NULL as its value. */
#define UNIV_SQL_NULL ULINT_UNDEFINED
#include <stdio.h>
#include "ut0dbg.h"
#include "ut0ut.h"
#include "db0err.h"
#endif

View File

@ -1,181 +0,0 @@
/***************************************************************************
Version control for database, common definitions, and include files
(c) 1994 - 1996 Innobase Oy
Created 1/20/1994 Heikki Tuuri
****************************************************************************/
#ifndef univ_i
#define univ_i
#define UNIV_INTEL
#define UNIV_PENTIUM
/* If UNIV_WINNT is not defined, we assume Windows 95 */
#define UNIV_WINNT
#define UNIV_WINNT4
#define UNIV_VISUALC
/* DEBUG VERSION CONTROL
===================== */
/* Make a profiler version where mutex_fence does not use CPUID and therefore
is not totally safe. The sync-library must be recompiled before profiling. */
/*
#define UNIV_PROFILE
*/
/* When the following flag is defined, also mutex lock word reset to 0
in mutex_exit is performed using a serializing instruction, which does not
allow speculative reads be performed before memory writes */
/*
#define SYNC_SERIALIZE_MUTEX_RESET
*/
/* Make a non-inline debug version */
#define UNIV_DEBUG
#define UNIV_MEM_DEBUG
#define UNIV_SYNC_DEBUG
#define UNIV_SEARCH_DEBUG
#define UNIV_IBUF_DEBUG
#define UNIV_SEARCH_PERF_STAT
#define UNIV_SYNC_PERF_STAT
#define UNIV_LIGHT_MEM_DEBUG
#define YYDEBUG 1
/*
#define UNIV_SQL_DEBUG
#define UNIV_LOG_DEBUG
*/
/* the above option prevents forcing of log to disk
at a buffer page write: it should be tested with this
option off; also some ibuf tests are suppressed */
/*
#define UNIV_BASIC_LOG_DEBUG
*/
/* the above option enables basic recovery debugging:
new allocated file pages are reset */
/* The debug version is slower, thus we may change the length of test loops
depending on the UNIV_DBC parameter */
#ifdef UNIV_DEBUG
#define UNIV_DBC 1
#else
#define UNIV_DBC 100
#endif
#ifndef UNIV_DEBUG
/* Definition for inline version */
#ifdef UNIV_VISUALC
#define UNIV_INLINE __inline
#elif defined(UNIV_GNUC)
#define UNIV_INLINE extern __inline__
#endif
#else
/* If we want to compile a noninlined version we use the following macro
definitions: */
#define UNIV_NONINL
#define UNIV_INLINE
#endif /* UNIV_DEBUG */
/* If the compiler does not know inline specifier, we use: */
/*
#define UNIV_INLINE static
*/
/*
MACHINE VERSION CONTROL
=======================
*/
#ifdef UNIV_PENTIUM
/* In a 32-bit computer word size is 4 */
#define UNIV_WORD_SIZE 4
/* The following alignment is used in memory allocations in memory heap
management to ensure correct alignment for doubles etc. */
#define UNIV_MEM_ALIGNMENT 8
/* The following alignment is used in aligning lints etc. */
#define UNIV_WORD_ALIGNMENT UNIV_WORD_SIZE
#endif
/*
DATABASE VERSION CONTROL
========================
*/
/* The universal page size of the database */
#define UNIV_PAGE_SIZE 8192 /* NOTE! Currently, this has to be a
power of 2 and divisible by
UNIV_MEM_ALIGNMENT */
/* 2-based logarithm of UNIV_PAGE_SIZE */
#define UNIV_PAGE_SIZE_SHIFT 13
/* Do asynchronous io in buffer pool read/write operations */
#ifdef UNIV_WINNT
#define UNIV_ASYNC_IO
#endif
/* Do non-buffered io in buffer pool read/write operations */
#define UNIV_NON_BUFFERED_IO
/* Maximum number of parallel threads in a parallelized operation */
#define UNIV_MAX_PARALLELISM 32
/*
UNIVERSAL TYPE DEFINITIONS
==========================
*/
/*
typedef unsigned char byte;
*/
/* An other basic type we use is unsigned long integer which is intended to be
equal to the word size of the machine. */
typedef unsigned long int ulint;
typedef long int lint;
/* The following type should be at least a 64-bit floating point number */
typedef double utfloat;
/* The 'undefined' value for a ulint */
#define ULINT_UNDEFINED ((ulint)(-1))
/* The undefined 32-bit unsigned integer */
#define ULINT32_UNDEFINED 0xFFFFFFFF
/* Maximum value for a ulint */
#define ULINT_MAX ((ulint)(-2))
/* Definition of the boolean type */
#ifndef bool
typedef ulint bool;
#endif
#define TRUE 1
#define FALSE 0
/* The following number as the length of a logical field means that the field
has the SQL NULL as its value. */
#define UNIV_SQL_NULL ULINT_UNDEFINED
#include <stdio.h>
#include "ut0dbg.h"
#include "ut0ut.h"
#include "db0err.h"
#endif

View File

@ -66,28 +66,6 @@ sess_open(
byte* addr_buf, /* in: client address */ byte* addr_buf, /* in: client address */
ulint addr_len); /* in: client address length */ ulint addr_len); /* in: client address length */
/************************************************************************* /*************************************************************************
Closes a session, freeing the memory occupied by it. */
void
sess_close(
/*=======*/
sess_t* sess); /* in, own: session object */
/*************************************************************************
Raises an SQL error. */
void
sess_raise_error_low(
/*=================*/
trx_t* trx, /* in: transaction */
ulint err_no, /* in: error number */
ulint type, /* in: more info of the error, or 0 */
dict_table_t* table, /* in: dictionary table or NULL */
dict_index_t* index, /* in: table index or NULL */
dtuple_t* tuple, /* in: tuple to insert or NULL */
rec_t* rec, /* in: record or NULL */
char* err_str);/* in: arbitrary null-terminated error string,
or NULL */
/*************************************************************************
Closes a session, freeing the memory occupied by it, if it is in a state Closes a session, freeing the memory occupied by it, if it is in a state
where it should be closed. */ where it should be closed. */
@ -117,16 +95,6 @@ sess_srv_msg_send_simple(
ulint rel_kernel); /* in: SESS_RELEASE_KERNEL or ulint rel_kernel); /* in: SESS_RELEASE_KERNEL or
SESS_NOT_RELEASE_KERNEL */ SESS_NOT_RELEASE_KERNEL */
/*************************************************************************** /***************************************************************************
Processes a message from a client. NOTE: May release the kernel mutex
temporarily. */
void
sess_receive_msg_rel_kernel(
/*========================*/
sess_t* sess, /* in: session */
byte* str, /* in: message string */
ulint len); /* in: message length */
/***************************************************************************
When a command has been completed, this function sends the message about it When a command has been completed, this function sends the message about it
to the client. */ to the client. */
@ -136,17 +104,6 @@ sess_command_completed_message(
sess_t* sess, /* in: session */ sess_t* sess, /* in: session */
byte* msg, /* in: message buffer */ byte* msg, /* in: message buffer */
ulint len); /* in: message data length */ ulint len); /* in: message data length */
/***********************************************************************
Starts a new connection and a session, or starts a query based on a client
message. This is called by a SRV_COM thread. */
void
sess_process_cli_msg(
/*=================*/
byte* str, /* in: message string */
ulint len, /* in: string length */
byte* addr, /* in: address string */
ulint alen); /* in: address length */
/* The session handle. All fields are protected by the kernel mutex */ /* The session handle. All fields are protected by the kernel mutex */

View File

@ -176,19 +176,19 @@ ut_fold_string(
/* out: folded value */ /* out: folded value */
char* str) /* in: null-terminated string */ char* str) /* in: null-terminated string */
{ {
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
ulint i = 0; ulint i = 0;
#endif #endif
ulint fold = 0; ulint fold = 0;
ut_ad(str); ut_ad(str);
while (*str != '\0') { while (*str != '\0') {
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
i++; i++;
ut_a(i < 100); ut_a(i < 100);
#endif #endif
fold = ut_fold_ulint_pair(fold, (ulint)(*str)); fold = ut_fold_ulint_pair(fold, (ulint)(*str));
str++; str++;

View File

@ -3063,11 +3063,6 @@ retry:
ut_a(strlen(lock_latest_err_buf) < 4100); ut_a(strlen(lock_latest_err_buf) < 4100);
/*
sess_raise_error_low(trx, DB_DEADLOCK, lock->type_mode, table,
index, NULL, NULL, NULL);
*/
return(TRUE); return(TRUE);
} }

View File

@ -1,648 +0,0 @@
/******************************************************
Recovery
(c) 1997 Innobase Oy
Created 9/20/1997 Heikki Tuuri
*******************************************************/
#include "log0recv.h"
#ifdef UNIV_NONINL
#include "log0recv.ic"
#endif
#include "mem0mem.h"
#include "buf0buf.h"
#include "buf0flu.h"
#include "srv0srv.h"
/* Size of block reads when the log groups are scanned forward to do
roll-forward */
#define RECV_SCAN_SIZE (4 * UNIV_PAGE_SIZE)
/* Size of block reads when the log groups are scanned backwards to synchronize
them */
#define RECV_BACK_SCAN_SIZE (4 * UNIV_PAGE_SIZE)
recv_sys_t* recv_sys = NULL;
recv_recover_page(block->frame, block->space, block->offset);
/************************************************************
Creates the recovery system. */
void
recv_sys_create(void)
/*=================*/
{
ut_a(recv_sys == NULL);
recv_sys = mem_alloc(sizeof(recv_t));
mutex_create(&(recv_sys->mutex));
recv_sys->hash = NULL;
recv_sys->heap = NULL;
}
/************************************************************
Inits the recovery system for a recovery operation. */
void
recv_sys_init(void)
/*===============*/
{
recv_sys->hash = hash_create(buf_pool_get_curr_size() / 64);
recv_sys->heap = mem_heap_create_in_buffer(256);
}
/************************************************************
Empties the recovery system. */
void
recv_sys_empty(void)
/*================*/
{
mutex_enter(&(recv_sys->mutex));
hash_free(recv_sys->hash);
mem_heap_free(recv_sys->heap);
recv_sys->hash = NULL;
recv_sys->heap = NULL;
mutex_exit(&(recv_sys->mutex));
}
/***********************************************************
For recovery purposes copies the log buffer to a group to synchronize log
data. */
static
void
recv_log_buf_flush(
/*===============*/
log_group_t* group, /* in: log group */
dulint start_lsn, /* in: start lsn of the log data in
the log buffer; must be divisible by
OS_FILE_LOG_BLOCK_SIZE */
dulint end_lsn) /* in: end lsn of the log data in the
log buffer; must be divisible by
OS_FILE_LOG_BLOCK_SIZE */
{
ulint len;
ut_ad(mutex_own(&(log_sys->mutex)));
len = ut_dulint_minus(end_lsn, start_lsn);
log_group_write_buf(LOG_RECOVER, group, log_sys->buf, len, start_lsn,
0);
}
/***********************************************************
Compares two buffers containing log segments and determines the highest lsn
where they match, if any. */
static
dulint
recv_log_bufs_cmp(
/*==============*/
/* out: if no match found, ut_dulint_zero or
if start_lsn == LOG_START_LSN, returns
LOG_START_LSN; otherwise the highest matching
lsn */
byte* recv_buf, /* in: buffer containing valid log data */
byte* buf, /* in: buffer of data from a possibly
incompletely written log group */
dulint start_lsn, /* in: buffer start lsn, must be divisible
by OS_FILE_LOG_BLOCK_SIZE and must be >=
LOG_START_LSN */
dulint end_lsn, /* in: buffer end lsn, must be divisible
by OS_FILE_LOG_BLOCK_SIZE */
dulint recovered_lsn) /* in: recovery succeeded up to this lsn */
{
ulint len;
ulint offset;
byte* log_block1;
byte* log_block2;
ulint no;
ulint data_len;
ut_ad(ut_dulint_cmp(start_lsn, LOG_START_LSN) >= 0);
if (ut_dulint_cmp(end_lsn, recovered_lsn) > 0) {
end_lsn = ut_dulint_align_up(recovered_lsn,
OS_FILE_LOG_BLOCK_SIZE);
}
len = ut_dulint_minus(end_lsn, start_lsn);
if (len == 0) {
goto no_match;
}
ut_ad(len % OS_FILE_LOG_BLOCK_SIZE == 0);
log_block1 = recv_buf + len;
log_block2 = buf + len;
for (;;) {
log_block1 -= OS_FILE_LOG_BLOCK_SIZE;
log_block2 -= OS_FILE_LOG_BLOCK_SIZE;
no = log_block_get_hdr_no(log_block1);
ut_a(no == log_block_get_trl_no(log_block1));
if ((no == log_block_get_hdr_no(log_block2))
&& (no == log_block_get_trl_no(log_block2))) {
/* Match found if the block is not corrupted */
data_len = log_block_get_data_len(log_block2);
if (0 == ut_memcmp(log_block1 + LOG_BLOCK_DATA,
log_block2 + LOG_BLOCK_DATA,
data_len - LOG_BLOCK_DATA)) {
/* Match found */
return(ut_dulint_add(start_lsn,
log_block2 - buf + data_len));
}
}
if (log_block1 == recv_buf) {
/* No match found */
break;
}
}
no_match:
if (ut_dulint_cmp(start_lsn, LOG_START_LSN) == 0) {
return(LOG_START_LSN);
}
return(ut_dulint_zero);
}
/************************************************************
Copies a log segment from the most up-to-date log group to the other log
group, so that it contains the latest log data. */
static
void
recv_copy_group(
/*============*/
log_group_t* up_to_date_group, /* in: the most up-to-date
log group */
log_group_t* group, /* in: copy to this log group */
dulint_lsn recovered_lsn) /* in: recovery succeeded up
to this lsn */
{
dulint start_lsn;
dulint end_lsn;
dulint match;
byte* buf;
byte* buf1;
ut_ad(mutex_own(&(log_sys->mutex)));
if (0 == ut_dulint_cmp(LOG_START_LSN, recovered_lsn)) {
return;
}
ut_ad(RECV_BACK_SCAN_SIZE <= log_sys->buf_size);
buf1 = mem_alloc(2 * RECV_BACK_SCAN_SIZE);
buf = ut_align(buf, RECV_BACK_SCAN_SIZE););
end_lsn = ut_dulint_align_up(recovered_lsn, RECV_BACK_SCAN_SIZE);
match = ut_dulint_zero;
for (;;) {
if (ut_dulint_cmp(ut_dulint_add(LOG_START_LSN,
RECV_BACK_SCAN_SIZE), end_lsn) >= 0) {
start_lsn = LOG_START_LSN;
} else {
start_lsn = ut_dulint_subtract(end_lsn,
RECV_BACK_SCAN_SIZE);
}
log_group_read_log_seg(LOG_RECOVER, buf, group, start_lsn,
end_lsn);
log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
up_to_date_group, start_lsn, end_lsn);
match = recv_log_bufs_cmp(log_sys->buf, buf, start_lsn,
end_lsn, recovered_lsn);
if (ut_dulint_cmp(match, recovered_lsn) != 0) {
recv_log_buf_flush(group, start_lsn, end_lsn);
}
if (!ut_dulint_zero(match)) {
mem_free(buf1);
return;
}
end_lsn = start_lsn;
}
}
/************************************************************
Copies a log segment from the most up-to-date log group to the other log
groups, so that they all contain the latest log data. Also writes the info
about the latest checkpoint to the groups, and inits the fields in the group
memory structs to up-to-date values. */
void
recv_synchronize_groups(
/*====================*/
log_group_t* up_to_date_group, /* in: the most up-to-date
log group */
dulint_lsn recovered_lsn, /* in: recovery succeeded up
to this lsn */
log_group_t* max_checkpoint_group) /* in: the group with the most
recent checkpoint info */
{
log_group_t* group;
ut_ad(mutex_own(&(log_sys->mutex)));
group = UT_LIST_GET_FIRST(log_sys->log_groups);
while (group) {
if (group != up_to_date_group) {
/* Copy log data */
recv_copy_group(group, up_to_date_group,
recovered_lsn);
}
if (group != max_checkpoint_group) {
/* Copy the checkpoint info to the group */
log_group_checkpoint(group);
mutex_exit(&(log_sys->mutex));
/* Wait for the checkpoint write to complete */
rw_lock_s_lock(&(log_sys->checkpoint_lock));
rw_lock_s_unlock(&(log_sys->checkpoint_lock));
mutex_enter(&(log_sys->mutex));
}
/* Update the fields in the group struct to correspond to
recovered_lsn */
log_group_set_fields(group, recovered_lsn);
group = UT_LIST_GET_NEXT(log_groups, group);
}
}
/************************************************************
Looks for the maximum consistent checkpoint from the log groups. */
static
ulint
recv_find_max_checkpoint(
/*=====================*/
/* out: error code or DB_SUCCESS */
log_group_t** max_group, /* out: max group */
ulint* max_field) /* out: LOG_CHECKPOINT_1 or
LOG_CHECKPOINT_2 */
{
log_group_t* group;
dulint max_no;
dulint cp_no;
ulint field;
ulint fold;
byte* buf;
ut_ad(mutex_own(&(log_sys->mutex)));
/* Look for the latest checkpoint from the log groups */
group = UT_LIST_GET_FIRST(log_sys->log_groups);
checkpoint_no = ut_dulint_zero;
checkpoint_lsn = ut_dulint_zero;
*max_group = NULL;
buf = log_sys->checkpoint_buf;
while (group) {
group->state = LOG_GROUP_CORRUPTED;
for (field = LOG_CHECKPOINT_1; field <= LOG_CHECKPOINT_2;
field += LOG_CHECKPOINT_2 - LOG_CHECKPOINT_1) {
log_group_read_checkpoint_info(group, field);
/* Check the consistency of the checkpoint info */
fold = ut_fold_binary(buf, LOG_CHECKPOINT_CHECKSUM_1);
if (fold != mach_read_from_4(buf
+ LOG_CHECKPOINT_CHECKSUM_1)) {
goto not_consistent;
}
fold = ut_fold_binary(buf + LOG_CHECKPOINT_LSN,
LOG_CHECKPOINT_CHECKSUM_2
- LOG_CHECKPOINT_LSN);
if (fold != mach_read_from_4(buf
+ LOG_CHECKPOINT_CHECKSUM_2)) {
goto not_consistent;
}
group->state = LOG_GROUP_OK;
group->lsn = mach_read_from_8(buf
+ LOG_CHECKPOINT_LSN);
group->lsn_offset = mach_read_from_4(buf
+ LOG_CHECKPOINT_OFFSET);
group->lsn_file_count = mach_read_from_4(
buf + LOG_CHECKPOINT_FILE_COUNT);
cp_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
if (ut_dulint_cmp(cp_no, max_no) >= 0) {
*max_group = group;
*max_field = field;
max_no = cp_no;
}
not_consistent:
}
group = UT_LIST_GET_NEXT(log_groups, group);
}
if (*max_group == NULL) {
return(DB_ERROR);
}
return(DB_SUCCESS);
}
/***********************************************************
Parses log records from a buffer and stores them to a hash table to wait
merging to file pages. If the hash table becomes too big, merges automatically
it to file pages. */
static
bool
recv_parse_and_hash_log_recs(
/*=========================*/
/* out: TRUE if limit_lsn has been reached */
byte* buf, /* in: buffer containing a log segment or
garbage */
ulint len, /* in: buffer length */
dulint start_lsn, /* in: buffer start lsn */
dulint limit_lsn, /* in: recover at least to this lsn */
dulint* recovered_lsn) /* out: was able to parse up to this lsn */
{
}
/************************************************************
Recovers from a checkpoint. When this function returns, the database is able
to start processing new user transactions, but the function
recv_recovery_from_checkpoint_finish should be called later to complete
the recovery and free the resources used in it. */
ulint
recv_recovery_from_checkpoint_start(
/*================================*/
/* out: error code or DB_SUCCESS */
dulint limit_lsn) /* in: recover up to this lsn if possible */
{
log_group_t* max_cp_group;
log_group_t* up_to_date_group;
ulint max_cp_field;
byte* buf;
ulint err;
dulint checkpoint_lsn;
dulint checkpoint_no;
dulint recovered_lsn;
dulint old_lsn;
dulint end_lsn;
dulint start_lsn;
bool finished;
dulint flush_start_lsn;
mutex_enter(&(log_sys->mutex));
/* Look for the latest checkpoint from any of the log groups */
err = recv_find_max_checkpoint(&max_cp_group, &max_cp_field);
if (err != DB_SUCCESS) {
mutex_exit(&(log_sys->mutex));
return(err);
}
log_group_read_checkpoint_info(max_cp_group, max_cp_field);
buf = log_sys->checkpoint_buf;
checkpoint_lsn = mach_read_from_8(buf + LOG_CHECKPOINT_LSN);
checkpoint_no = mach_read_from_8(buf + LOG_CHECKPOINT_NO);
if (ut_dulint_cmp(limit_lsn, checkpoint_lsn) < 0) {
mutex_exit(&(log_sys->mutex));
return(DB_ERROR);
}
/* Start reading the log groups from the checkpoint lsn up. The
variable flush_start_lsn tells a lsn up to which the log is known
to be contiguously written in all log groups. */
recovered_lsn = checkpoint_lsn;
flush_start_lsn = ut_dulint_align_down(checkpoint_lsn,
OS_FILE_LOG_BLOCK_SIZE);
up_to_date_group = max_cp_group;
ut_ad(RECV_SCAN_SIZE <= log_sys->buf_size);
group = UT_LIST_GET_FIRST(log_sys->log_groups);
while (group) {
finished = FALSE;
if (group->state == LOG_GROUP_CORRUPTED) {
finished = TRUE;
}
start_lsn = flush_start_lsn;
while (!finished) {
end_lsn = ut_dulint_add(start_lsn, RECV_SCAN_SIZE);
log_group_read_log_seg(LOG_RECOVER, log_sys->buf,
group, start_lsn, end_lsn);
old_lsn = recovered_lsn;
finished = recv_parse_and_hash_log_recs(log_sys->buf,
RECV_SCAN_SIZE, start_lsn,
limit_lsn, &flush_start_lsn,
&recovered_lsn);
if (ut_dulint_cmp(recovered_lsn, old_lsn) > 0) {
/* We found a more up-to-date group */
up_to_date_group = group;
}
start_lsn = end_lsn;
}
group = UT_LIST_GET_NEXT(log_groups, group);
}
/* Delete possible corrupted or extra log records from all log
groups */
recv_truncate_groups(recovered_lsn);
/* Synchronize the uncorrupted log groups to the most up-to-date log
group; we may also have to copy checkpoint info to groups */
log_sys->next_checkpoint_lsn = checkpoint_lsn;
log_sys->next_checkpoint_no = checkpoint_no;
recv_synchronize_groups(up_to_date_group, _lsn, max_cp_group);
log_sys->next_checkpoint_no = ut_dulint_add(checkpoint_no, 1);
/* The database is now ready to start almost normal processing of user
transactions */
return(DB_SUCCESS);
}
/************************************************************
Completes recovery from a checkpoint. */
void
recv_recovery_from_checkpoint_finish(void)
/*======================================*/
{
/* Rollback the uncommitted transactions which have no user session */
trx_rollback_all_without_sess();
/* Merge the hashed log records */
recv_merge_hashed_log_recs();
/* Free the resources of the recovery system */
recv_sys_empty();
}
/****************************************************************
Writes to the log a record about incrementing the row id counter. */
UNIV_INLINE
void
log_write_row_id_incr_rec(void)
/*===========================*/
{
log_t* log = log_sys;
ulint data_len;
mutex_enter(&(log->mutex));
data_len = (log->buf_free % OS_FILE_LOG_BLOCK_SIZE) + 1;
if (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) {
/* The string does not fit within the current log block
or the the block would become full */
mutex_exit(&(log->mutex));
log_write_row_id_incr_rec_slow();
return;
}
*(log->buf + log->buf_free) = MLOG_INCR_ROW_ID | MLOG_SINGLE_REC_FLAG;
log_block_set_data_len(ut_align_down(log->buf + log->buf_free,
OS_FILE_LOG_BLOCK_SIZE),
data_len);
#ifdef UNIV_LOG_DEBUG
log->old_buf_free = log->buf_free;
log->old_lsn = log->lsn;
log_check_log_recs(log->buf + log->buf_free, 1, log->lsn);
#endif
log->buf_free++;
ut_ad(log->buf_free <= log->buf_size);
UT_DULINT_INC(log->lsn);
mutex_exit(&(log->mutex));
}
/****************************************************************
Writes to the log a record about incrementing the row id counter. */
static
void
log_write_row_id_incr_rec_slow(void)
/*================================*/
{
byte type;
log_reserve_and_open(1);
type = MLOG_INCR_ROW_ID | MLOG_SINGLE_REC_FLAG;
log_write_low(&type, 1);
log_close();
log_release();
}
/**************************************************************************
Parses and applies a log record MLOG_SET_ROW_ID. */
byte*
dict_hdr_parse_set_row_id(
/*======================*/
/* out: end of log record or NULL */
byte* ptr, /* in: buffer */
byte* end_ptr,/* in: buffer end */
page_t* page) /* in: page or NULL */
{
dulint dval;
ptr = mach_dulint_parse_compressed(ptr, end_ptr, &dval);
if (ptr == NULL) {
return(NULL);
}
if (!page) {
return(ptr);
}
mach_write_to_8(page + DICT_HDR + DICT_HDR_ROW_ID, dval);
return(ptr);
}

View File

@ -1,12 +0,0 @@
include ..\..\makefile.i
tsmach: ..\mach.lib tsmach.c
$(CCOM) $(CFL) -I.. -I..\.. ..\mach.lib ..\..\ut.lib ..\..\os.lib tsmach.c $(LFL)

View File

@ -1,158 +0,0 @@
/************************************************************************
The test module for the machine-dependent utilities
(c) 1995 Innobase Oy
Created 11/28/1995 Heikki Tuuri
*************************************************************************/
#include "../mach0data.h"
byte arr[4000000];
/*********************************************************************
Test for ulint write and read. */
void
test1(void)
/*=======*/
{
ulint a, i, j;
ulint tm, oldtm;
printf("-------------------------------------------\n");
printf("TEST 1. Speed test of ulint read and write \n");
a = 0;
oldtm = ut_clock();
for (j = 0; j < 100; j++) {
for (i = 0; i < 10000; i++) {
a += mach_read_from_4(arr + i * 4);
}
}
tm = ut_clock();
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
j * i, tm - oldtm);
oldtm = ut_clock();
for (j = 0; j < 100; j++) {
for (i = 0; i < 10000; i++) {
a += mach_read(arr + i * 4);
}
}
tm = ut_clock();
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
j * i, tm - oldtm);
oldtm = ut_clock();
for (j = 0; j < 100; j++) {
for (i = 0; i < 10000; i++) {
a += mach_read_from_4(arr + i * 4 + 1);
}
}
tm = ut_clock();
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
j * i, tm - oldtm);
oldtm = ut_clock();
for (j = 0; j < 100; j++) {
for (i = 0; i < 10000; i++) {
a += mach_read(arr + i * 4 + 1);
}
}
tm = ut_clock();
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
j * i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 1000000; i++) {
a += mach_read_from_4(arr + i * 4);
}
tm = ut_clock();
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 1000000; i++) {
a += mach_read(arr + i * 4);
}
tm = ut_clock();
printf("Wall clock time for read of %lu ulints %lu millisecs\n",
i, tm - oldtm);
oldtm = ut_clock();
for (j = 0; j < 100; j++) {
for (i = 0; i < 10000; i++) {
a += mach_read_from_2(arr + i * 2);
}
}
tm = ut_clock();
printf("Wall clock time for read of %lu 16-bit ints %lu millisecs\n",
j * i, tm - oldtm);
}
/*********************************************************************
Test for ulint write and read. */
void
test2(void)
/*=======*/
{
ulint a[2];
printf("-------------------------------------------\n");
printf("TEST 2. Correctness test of ulint read and write \n");
mach_write_to_4((byte*)&a, 737237727);
ut_a(737237727 == mach_read_from_4((byte*)&a));
mach_write_to_2((byte*)&a, 7372);
ut_a(7372 == mach_read_from_2((byte*)&a));
mach_write_to_1((byte*)&a, 27);
ut_a(27 == mach_read_from_1((byte*)&a));
mach_write((byte*)&a, 737237727);
ut_a(737237727 == mach_read((byte*)&a));
}
void
main(void)
{
test1();
test2();
printf("TEST SUCCESSFULLY COMPLETED!\n");
}

View File

@ -406,12 +406,12 @@ mem_heap_validate_or_print(
ulint total_len = 0; ulint total_len = 0;
ulint block_count = 0; ulint block_count = 0;
ulint phys_len = 0; ulint phys_len = 0;
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
ulint len; ulint len;
byte* field; byte* field;
byte* user_field; byte* user_field;
ulint check_field; ulint check_field;
#endif #endif
/* Pessimistically, we set the parameters to error values */ /* Pessimistically, we set the parameters to error values */
if (us_size != NULL) { if (us_size != NULL) {
@ -446,7 +446,7 @@ mem_heap_validate_or_print(
return; return;
} }
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
/* We can trace the fields of the block only in the debug /* We can trace the fields of the block only in the debug
version */ version */
if (print) { if (print) {
@ -502,7 +502,7 @@ mem_heap_validate_or_print(
return; return;
} }
#endif #endif
block = UT_LIST_GET_NEXT(list, block); block = UT_LIST_GET_NEXT(list, block);
block_count++; block_count++;
@ -714,7 +714,7 @@ mem_all_freed(void)
/*===============*/ /*===============*/
/* out: TRUE if no heaps exist */ /* out: TRUE if no heaps exist */
{ {
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
mem_hash_node_t* node; mem_hash_node_t* node;
ulint heap_count = 0; ulint heap_count = 0;
@ -744,14 +744,14 @@ mem_all_freed(void)
return(FALSE); return(FALSE);
} }
#else #else
printf( printf(
"Sorry, non-debug version cannot check if all memory is freed.\n"); "Sorry, non-debug version cannot check if all memory is freed.\n");
return(FALSE); return(FALSE);
#endif #endif
} }
/********************************************************************* /*********************************************************************
@ -762,7 +762,7 @@ mem_validate_no_assert(void)
/*========================*/ /*========================*/
/* out: TRUE if error */ /* out: TRUE if error */
{ {
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
mem_hash_node_t* node; mem_hash_node_t* node;
ulint n_heaps = 0; ulint n_heaps = 0;
@ -823,13 +823,13 @@ mem_validate_no_assert(void)
return(error); return(error);
#else #else
printf("Sorry, non-debug version cannot validate dynamic memory\n"); printf("Sorry, non-debug version cannot validate dynamic memory\n");
return(FALSE); return(FALSE);
#endif #endif
} }
/**************************************************************** /****************************************************************

View File

@ -294,13 +294,13 @@ mem_heap_block_free(
init_block = block->init_block; init_block = block->init_block;
block->magic_n = MEM_FREED_BLOCK_MAGIC_N; block->magic_n = MEM_FREED_BLOCK_MAGIC_N;
#ifdef UNIV_MEM_DEBUG #ifdef UNIV_MEM_DEBUG
/* In the debug version we set the memory to a random combination /* In the debug version we set the memory to a random combination
of hex 0xDE and 0xAD. */ of hex 0xDE and 0xAD. */
mem_erase_buf((byte*)block, len); mem_erase_buf((byte*)block, len);
#endif #endif
if (init_block) { if (init_block) {
/* Do not have to free: do nothing */ /* Do not have to free: do nothing */

View File

@ -1,12 +0,0 @@
include ..\..\makefile.i
tsmem: ..\mem.lib tsmem.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\mem.lib ..\..\btr.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\os.lib tsmem.c $(LFL)

View File

@ -1,497 +0,0 @@
/************************************************************************
The test module for the memory management of Innobase
(c) 1994, 1995 Innobase Oy
Created 6/10/1994 Heikki Tuuri
*************************************************************************/
#include "../mem0mem.h"
#include "sync0sync.h"
#include "ut0rnd.h"
mem_heap_t* heap_arr[1200];
byte* buf_arr[10000];
ulint rnd_arr[10000];
#ifdef UNIV_DEBUG
/*********************************************************************
Debug version test. */
void
test1(void)
/*=======*/
{
mem_heap_t* heap_1, *heap_2;
byte* buf_1, *buf_2, *buf_3;
byte check;
bool error;
ulint i;
ulint j;
ulint sum;
ulint user_size;
ulint phys_size, phys_size_1, phys_size_2;
ulint n_blocks;
ulint p;
byte block[1024];
byte* top_1, *top_2;
/* For this test to work the memory alignment must be
even (presumably a reasonable assumption) */
ut_a(0 == (UNIV_MEM_ALIGNMENT & 1));
printf("-------------------------------------------\n");
printf("TEST 1. Basic test \n");
heap_1 = mem_heap_create(0);
buf_1 = mem_heap_alloc(heap_1, 11);
heap_2 = mem_heap_create(0);
buf_2 = mem_heap_alloc(heap_1, 15);
/* Test that the field is properly initialized */
for (i = 0; i < 11; i++) {
ut_a((*(buf_1 + i) == 0xBA) || (*(buf_1 + i) == 0xBE));
}
check = *(buf_1 + 11);
mem_validate();
/* Make an advertent error in the heap */
(*(buf_1 + 11))++;
error = mem_validate_no_assert();
ut_a(error);
/* Fix the error in heap before freeing */
*(buf_1 + 11) = check;
mem_print_info();
/* Free the top buffer buf_2 */
mem_heap_free_top(heap_1, 15);
/* Test that the field is properly erased */
for (i = 0; i < 15; i++) {
ut_a((*(buf_2 + i) == 0xDE) || (*(buf_2 + i) == 0xAD));
}
/* Test that a new buffer is allocated from the same position
as buf_2 */
buf_3 = mem_heap_alloc(heap_1, 15);
ut_a(buf_3 == buf_2);
mem_heap_free(heap_1);
/* Test that the field is properly erased */
for (i = 0; i < 11; i++) {
ut_a((*(buf_1 + i) == 0xDE) || (*(buf_1 + i) == 0xAD));
}
mem_validate();
mem_print_info();
printf("-------------------------------------------\n");
printf("TEST 2. Test of massive allocation and freeing\n");
sum = 0;
for (i = 0; i < 10000; i++) {
j = ut_rnd_gen_ulint() % 16 + 15;
sum = sum + j;
buf_1 = mem_heap_alloc(heap_2, j);
rnd_arr[i] = j;
buf_arr[i] = buf_1;
ut_a(buf_1 == mem_heap_get_top(heap_2, j));
}
mem_heap_validate_or_print(heap_2, NULL, FALSE, &error, &user_size,
&phys_size_1,
&n_blocks);
ut_a(!error);
ut_a(user_size == sum);
(*(buf_1 - 1))++;
ut_a(mem_validate_no_assert());
(*(buf_1 - 1))--;
mem_print_info();
for (p = 10000; p > 0 ; p--) {
j = rnd_arr[p - 1];
ut_a(buf_arr[p - 1] == mem_heap_get_top(heap_2, j));
mem_heap_free_top(heap_2, j);
}
mem_print_info();
mem_heap_free(heap_2);
mem_print_info();
printf("-------------------------------------------\n");
printf("TEST 3. More tests on the validating \n");
heap_1 = mem_heap_create(UNIV_MEM_ALIGNMENT * 20);
buf_1 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT * 20);
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error, &user_size,
&phys_size_1,
&n_blocks);
ut_a((ulint)(buf_1 - (byte*)heap_1) == (MEM_BLOCK_HEADER_SIZE
+ MEM_FIELD_HEADER_SIZE));
mem_validate();
mem_print_info();
ut_a(user_size == UNIV_MEM_ALIGNMENT * 20);
ut_a(phys_size_1 == (ulint)(ut_calc_align(MEM_FIELD_HEADER_SIZE
+ UNIV_MEM_ALIGNMENT * 20
+ MEM_FIELD_TRAILER_SIZE,
UNIV_MEM_ALIGNMENT)
+ MEM_BLOCK_HEADER_SIZE));
ut_a(n_blocks == 1);
buf_2 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT * 3 - 1);
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
&user_size, &phys_size_2,
&n_blocks);
printf("Physical size of the heap %ld\n", phys_size_2);
ut_a(!error);
ut_a(user_size == UNIV_MEM_ALIGNMENT * 23 - 1);
ut_a(phys_size_2 == (ulint) (phys_size_1
+ ut_calc_align(MEM_FIELD_HEADER_SIZE
+ phys_size_1 * 2
+ MEM_FIELD_TRAILER_SIZE,
UNIV_MEM_ALIGNMENT)
+ MEM_BLOCK_HEADER_SIZE));
ut_a(n_blocks == 2);
buf_3 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT * 3 + 5);
ut_a((ulint)(buf_3 - buf_2) == ut_calc_align(
(UNIV_MEM_ALIGNMENT * 3
+ MEM_FIELD_TRAILER_SIZE),
UNIV_MEM_ALIGNMENT)
+ MEM_FIELD_HEADER_SIZE);
ut_memcpy(buf_3, buf_2, UNIV_MEM_ALIGNMENT * 3);
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
&user_size, &phys_size,
&n_blocks);
ut_a(!error);
ut_a(user_size == UNIV_MEM_ALIGNMENT * 26 + 4);
ut_a(phys_size == phys_size_2);
ut_a(n_blocks == 2);
/* Make an advertent error to buf_3 */
(*(buf_3 - 1))++;
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
&user_size, &phys_size,
&n_blocks);
ut_a(error);
ut_a(user_size == 0);
ut_a(phys_size == 0);
ut_a(n_blocks == 0);
/* Fix the error and make another */
(*(buf_3 - 1))--;
(*(buf_3 + UNIV_MEM_ALIGNMENT * 3 + 5))++;
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
&user_size, &phys_size,
&n_blocks);
ut_a(error);
(*(buf_3 + UNIV_MEM_ALIGNMENT * 3 + 5))--;
buf_1 = mem_heap_alloc(heap_1, UNIV_MEM_ALIGNMENT + 4);
ut_a((ulint)(buf_1 - buf_3) == ut_calc_align(UNIV_MEM_ALIGNMENT * 3 + 5
+ MEM_FIELD_TRAILER_SIZE ,
UNIV_MEM_ALIGNMENT)
+ MEM_FIELD_HEADER_SIZE);
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
&user_size, &phys_size,
&n_blocks);
ut_a(!error);
ut_a(user_size == UNIV_MEM_ALIGNMENT * 27 + 8);
ut_a(phys_size == phys_size_2);
ut_a(n_blocks == 2);
mem_print_info();
mem_heap_free(heap_1);
printf("-------------------------------------------\n");
printf("TEST 4. Test of massive allocation \n");
printf("of heaps to test the hash table\n");
for (i = 0; i < 500; i++) {
heap_arr[i] = mem_heap_create(i);
buf_2 = mem_heap_alloc(heap_arr[i], 2 * i);
}
mem_validate();
for (i = 0; i < 500; i++) {
mem_heap_free(heap_arr[i]);
}
mem_validate();
mem_print_info();
/* Validating a freed heap should generate an error */
mem_heap_validate_or_print(heap_1, NULL, FALSE, &error,
NULL, NULL, NULL);
ut_a(error);
printf("-------------------------------------------\n");
printf("TEST 5. Test of mem_alloc and mem_free \n");
buf_1 = mem_alloc(11100);
buf_2 = mem_alloc(23);
ut_memcpy(buf_2, buf_1, 23);
mem_validate();
mem_print_info();
mem_free(buf_1);
mem_free(buf_2);
mem_validate();
printf("-------------------------------------------\n");
printf("TEST 6. Test of mem_heap_print \n");
heap_1 = mem_heap_create(0);
buf_1 = mem_heap_alloc(heap_1, 7);
ut_memcpy(buf_1, "Pascal", 7);
for (i = 0; i < 10; i++) {
buf_1 = mem_heap_alloc(heap_1, 6);
ut_memcpy(buf_1, "Cobol", 6);
}
printf("A heap with 1 Pascal and 10 Cobol's\n");
mem_heap_print(heap_1);
for (i = 0; i < 10; i++) {
mem_heap_free_top(heap_1, 6);
}
printf("A heap with 1 Pascal and 0 Cobol's\n");
mem_heap_print(heap_1);
ut_a(mem_all_freed() == FALSE);
mem_heap_free(heap_1);
ut_a(mem_all_freed() == TRUE);
mem_print_info();
printf("-------------------------------------------\n");
printf("TEST 7. Test of mem_heap_fast_create \n");
heap_1 = mem_heap_fast_create(1024, block);
buf_1 = mem_heap_alloc(heap_1, 7);
ut_memcpy(buf_1, "Pascal", 7);
for (i = 0; i < 1000; i++) {
buf_1 = mem_heap_alloc(heap_1, 6);
ut_memcpy(buf_1, "Cobol", 6);
}
for (i = 0; i < 1000; i++) {
mem_heap_free_top(heap_1, 6);
}
ut_a(mem_all_freed() == FALSE);
mem_heap_free(heap_1);
ut_a(mem_all_freed() == TRUE);
mem_print_info();
printf("-------------------------------------------\n");
printf("TEST 8. Test of heap top freeing \n");
heap_1 = mem_heap_fast_create(1024, block);
top_1 = mem_heap_get_heap_top(heap_1);
buf_1 = mem_heap_alloc(heap_1, 7);
ut_memcpy(buf_1, "Pascal", 7);
for (i = 0; i < 500; i++) {
buf_1 = mem_heap_alloc(heap_1, 6);
ut_memcpy(buf_1, "Cobol", 6);
}
top_2 = mem_heap_get_heap_top(heap_1);
for (i = 0; i < 500; i++) {
buf_1 = mem_heap_alloc(heap_1, 6);
ut_memcpy(buf_1, "Cobol", 6);
}
mem_heap_free_heap_top(heap_1, top_2);
mem_heap_free_heap_top(heap_1, top_1);
ut_a(mem_all_freed() == FALSE);
for (i = 0; i < 500; i++) {
buf_1 = mem_heap_alloc(heap_1, 6);
ut_memcpy(buf_1, "Cobol", 6);
}
mem_heap_empty(heap_1);
for (i = 0; i < 500; i++) {
buf_1 = mem_heap_alloc(heap_1, 6);
ut_memcpy(buf_1, "Cobol", 6);
}
mem_heap_free(heap_1);
ut_a(mem_all_freed() == TRUE);
mem_print_info();
}
#endif /* UNIV_DEBUG */
/****************************************************************
Allocation speed test. */
void
test2(void)
/*=======*/
{
mem_heap_t* heap;
ulint tm, oldtm;
ulint i;
byte* buf;
byte block[512];
printf("-------------------------------------------\n");
printf("TEST B1. Test of speed \n");
oldtm = ut_clock();
for (i = 0; i < 10000 * UNIV_DBC * UNIV_DBC; i++) {
heap = mem_heap_create(500);
mem_heap_free(heap);
}
tm = ut_clock();
printf("Time for %ld heap create-free pairs %ld millisecs.\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 10000 * UNIV_DBC * UNIV_DBC; i++) {
heap = mem_heap_fast_create(512, block);
mem_heap_free(heap);
}
tm = ut_clock();
printf("Time for %ld heap fast-create-free pairs %ld millisecs.\n",
i, tm - oldtm);
heap = mem_heap_create(500);
oldtm = ut_clock();
for (i = 0; i < 10000 * UNIV_DBC * UNIV_DBC; i++) {
buf = mem_heap_alloc(heap, 50);
mem_heap_free_top(heap, 50);
}
tm = ut_clock();
printf("Time for %ld heap alloc-free-top pairs %ld millisecs.\n",
i, tm - oldtm);
mem_heap_free(heap);
}
void
main(void)
{
sync_init();
mem_init(2500000);
#ifdef UNIV_DEBUG
test1();
#endif
test2();
ut_ad(sync_all_freed());
ut_ad(mem_all_freed());
printf("TEST SUCCESSFULLY COMPLETED!\n");
}

View File

@ -1,8 +0,0 @@
include ..\..\makefile.i
tsmtr: ..\mtr.lib tsmtr.c
$(CCOM) $(CFL) -I.. -I..\.. ..\mtr.lib ..\..\dyn.lib ..\..\log.lib ..\..\mach.lib ..\..\buf.lib ..\..\fil.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsmtr.c $(LFL)

View File

@ -1,531 +0,0 @@
/************************************************************************
The test module for the file system and buffer manager
(c) 1995 Innobase Oy
Created 11/16/1995 Heikki Tuuri
*************************************************************************/
#include "os0thread.h"
#include "os0file.h"
#include "ut0ut.h"
#include "sync0sync.h"
#include "mem0mem.h"
#include "fil0fil.h"
#include "..\buf0buf.h"
#include "..\buf0flu.h"
#include "..\buf0lru.h"
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[5];
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = fil_aio_wait(segment, &mess);
ut_a(ret);
buf_page_io_complete((buf_block_t*)mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/************************************************************************
Creates the test database files. */
void
create_db(void)
/*===========*/
{
ulint i;
buf_block_t* block;
byte* frame;
ulint j;
ulint tm, oldtm;
oldtm = ut_clock();
for (i = 0; i < 1; i++) {
for (j = 0; j < 4096; j++) {
block = buf_page_create(i, j);
frame = buf_block_get_frame(block);
rw_lock_x_lock(buf_page_get_lock(block));
if (j > 0) {
fil_page_set_prev(frame, j - 1);
} else {
fil_page_set_prev(frame, 0);
}
if (j < 4095) {
fil_page_set_next(frame, j + 1);
} else {
fil_page_set_next(frame, 0);
}
*((ulint*)(frame + 16)) = j;
buf_page_note_modification(block);
rw_lock_x_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
/* buf_LRU_print(); */
/* Flush the pool of dirty pages by reading low-offset pages */
for (i = 0; i < 1000; i++) {
block = buf_page_get(0, i, NULL);
frame = buf_block_get_frame(block);
rw_lock_s_lock(buf_page_get_lock(block));
ut_a(*((ulint*)(frame + 16)) == i);
rw_lock_s_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
/* buf_LRU_print(); */
os_thread_sleep(1000000);
ut_a(buf_all_freed());
}
/*************************************************************************
Creates the files for the file system test and inserts them to
the file system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[10];
os_thread_t thr[5];
os_thread_id_t id[5];
name[0] = 't';
name[1] = 's';
name[2] = 'f';
name[3] = 'i';
name[4] = 'l';
name[5] = 'e';
name[8] = '\0';
for (k = 0; k < 1; k++) {
for (i = 0; i < 1; i++) {
name[6] = (char)(k + (ulint)'a');
name[7] = (char)(i + (ulint)'a');
files[i] = os_file_create("j:\\tsfile4", OS_FILE_CREATE,
OS_FILE_TABLESPACE, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
"j:\\tsfile4", OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
}
ret = os_file_set_size(files[i], 4096 * 8192, 0);
ut_a(ret);
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create("noname", k, OS_FILE_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create("j:\\tsfile4", 4096, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
}
/************************************************************************
Reads the test database files. */
void
test1(void)
/*=======*/
{
ulint i, j, k;
buf_block_t* block;
byte* frame;
ulint tm, oldtm;
buf_flush_batch(BUF_FLUSH_LIST, 1000);
os_thread_sleep(1000000);
buf_all_freed();
oldtm = ut_clock();
for (k = 0; k < 1; k++) {
for (i = 0; i < 1; i++) {
for (j = 0; j < 409; j++) {
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
rw_lock_s_lock(buf_page_get_lock(block));
ut_a(*((ulint*)(frame + 16)) == j);
rw_lock_s_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
}
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
}
/************************************************************************
Reads the test database files. */
void
test2(void)
/*=======*/
{
ulint i, j, k, rnd;
buf_block_t* block;
byte* frame;
ulint tm, oldtm;
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 100; k++) {
rnd += 23651;
rnd = rnd % 4096;
i = rnd / 4096;
j = rnd % 2048;
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
rw_lock_s_lock(buf_page_get_lock(block));
ut_a(*((ulint*)(frame + 16)) == j);
rw_lock_s_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
tm = ut_clock();
printf("Wall clock time for random read %lu milliseconds\n",
tm - oldtm);
}
/************************************************************************
Reads the test database files. */
void
test4(void)
/*=======*/
{
ulint i, j, k, rnd;
buf_block_t* block;
byte* frame;
ulint tm, oldtm;
/* Flush the pool of high-offset pages */
for (i = 0; i < 1000; i++) {
block = buf_page_get(0, i, NULL);
frame = buf_block_get_frame(block);
rw_lock_s_lock(buf_page_get_lock(block));
ut_a(*((ulint*)(frame + 16)) == i);
rw_lock_s_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
printf("Test starts\n");
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 400; k++) {
rnd += 4357;
i = 0;
j = 1001 + rnd % 3000;
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
rw_lock_s_lock(buf_page_get_lock(block));
ut_a(*((ulint*)(frame + 16)) == j);
rw_lock_s_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
tm = ut_clock();
printf(
"Wall clock time for %lu random no read-ahead %lu milliseconds\n",
k, tm - oldtm);
/* Flush the pool of high-offset pages */
for (i = 0; i < 1000; i++) {
block = buf_page_get(0, i, NULL);
frame = buf_block_get_frame(block);
rw_lock_s_lock(buf_page_get_lock(block));
ut_a(*((ulint*)(frame + 16)) == i);
rw_lock_s_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
printf("Test starts\n");
oldtm = ut_clock();
rnd = 123;
for (k = 0; k < 400; k++) {
rnd += 4357;
i = 0;
j = 1001 + rnd % 400;
block = buf_page_get(i, j, NULL);
frame = buf_block_get_frame(block);
rw_lock_s_lock(buf_page_get_lock(block));
ut_a(*((ulint*)(frame + 16)) == j);
rw_lock_s_unlock(buf_page_get_lock(block));
buf_page_release(block);
}
tm = ut_clock();
printf(
"Wall clock time for %lu random read-ahead %lu milliseconds\n",
k, tm - oldtm);
}
/************************************************************************
Tests speed of CPU algorithms. */
void
test3(void)
/*=======*/
{
ulint i, j;
buf_block_t* block;
ulint tm, oldtm;
for (i = 0; i < 400; i++) {
block = buf_page_get(0, i, NULL);
buf_page_release(block);
}
os_thread_sleep(2000000);
oldtm = ut_clock();
for (j = 0; j < 500; j++) {
for (i = 0; i < 200; i++) {
block = buf_page_get(0, i, NULL);
/*
rw_lock_s_lock(buf_page_get_lock(block));
rw_lock_s_unlock(buf_page_get_lock(block));
*/
buf_page_release(block);
}
}
tm = ut_clock();
printf("Wall clock time for %lu page get-release %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (j = 0; j < 500; j++) {
for (i = 0; i < 200; i++) {
buf_block_get(block);
/*
rw_lock_s_lock(buf_page_get_lock(block));
rw_lock_s_unlock(buf_page_get_lock(block));
*/
buf_page_release(block);
}
}
tm = ut_clock();
printf("Wall clock time for %lu block get-release %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 100000; i++) {
block = buf_block_alloc();
buf_block_free(block);
}
tm = ut_clock();
printf("Wall clock time for %lu block alloc-free %lu milliseconds\n",
i, tm - oldtm);
ha_print_info(buf_pool->page_hash);
}
/************************************************************************
Frees the spaces in the file system. */
void
free_system(void)
/*=============*/
{
ulint i;
for (i = 0; i < 1; i++) {
fil_space_free(i);
}
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
ulint n;
oldtm = ut_clock();
os_aio_init(160, 5);
sync_init();
mem_init();
fil_init(26); /* Allow 25 open files at a time */
buf_pool_init(1000, 1000);
buf_validate();
ut_a(fil_validate());
create_files();
create_db();
buf_validate();
test1();
test3();
test4();
test2();
buf_validate();
n = buf_flush_batch(BUF_FLUSH_LIST, 500);
os_thread_sleep(1000000);
buf_all_freed();
free_system();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,158 +0,0 @@
/************************************************************************
The test module for the mini-transaction utilities
(c) 1995 Innobase Oy
Created 11/26/1995 Heikki Tuuri
*************************************************************************/
#include "sync0sync.h"
#include "sync0rw.h"
#include "mem0mem.h"
#include "log0log.h"
#include "..\mtr0mtr.h"
#include "..\mtr0log.h"
rw_lock_t rwl[MTR_BUF_MEMO_SIZE];
/*********************************************************************
Test for mtr buffer */
void
test1(void)
/*=======*/
{
ulint i;
mtr_t mtr;
printf("-------------------------------------------\n");
printf("MTR-TEST 1. Test of mtr buffer\n");
mtr_start(&mtr);
for (i = 0; i < MTR_BUF_MEMO_SIZE; i++) {
rw_lock_create(rwl + i);
}
for (i = 0; i < MTR_BUF_MEMO_SIZE; i++) {
rw_lock_s_lock(rwl + i);
mtr_memo_push(&mtr, rwl + i, MTR_MEMO_S_LOCK);
}
mtr_commit(&mtr);
rw_lock_list_print_info();
ut_ad(rw_lock_n_locked() == 0);
}
/************************************************************************
Speed test function. */
void
speed_mtr(void)
/*===========*/
{
mtr_t mtr;
mtr_start(&mtr);
mtr_s_lock(rwl, &mtr);
mtr_s_lock(rwl + 1, &mtr);
mtr_s_lock(rwl + 2, &mtr);
mtr_commit(&mtr);
}
/************************************************************************
Speed test function without mtr. */
void
speed_no_mtr(void)
/*===========*/
{
rw_lock_s_lock(rwl);
rw_lock_s_lock(rwl + 1);
rw_lock_s_lock(rwl + 2);
rw_lock_s_unlock(rwl + 2);
rw_lock_s_unlock(rwl + 1);
rw_lock_s_unlock(rwl);
}
/************************************************************************
Speed test function. */
void
test2(void)
/*======*/
{
ulint tm, oldtm;
ulint i, j;
mtr_t mtr;
byte buf[50];
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
speed_mtr();
}
tm = ut_clock();
printf("Wall clock time for %lu mtrs %lu milliseconds\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
speed_no_mtr();
}
tm = ut_clock();
printf("Wall clock time for %lu no-mtrs %lu milliseconds\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 4 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
for (j = 0; j < 250; j++) {
mlog_catenate_ulint(&mtr, 5, MLOG_1BYTE);
mlog_catenate_ulint(&mtr, i, MLOG_4BYTES);
mlog_catenate_ulint(&mtr, i + 1, MLOG_4BYTES);
mlog_catenate_string(&mtr, buf, 50);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall clock time for %lu log writes %lu milliseconds\n",
i * j, tm - oldtm);
mtr_start(&mtr);
for (j = 0; j < 250; j++) {
mlog_catenate_ulint(&mtr, 5, MLOG_1BYTE);
mlog_catenate_ulint(&mtr, i, MLOG_4BYTES);
mlog_catenate_ulint(&mtr, i + 1, MLOG_4BYTES);
mlog_catenate_string(&mtr, buf, 50);
}
mtr_print(&mtr);
mtr_commit(&mtr);
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
oldtm = ut_clock();
sync_init();
mem_init();
log_init();
test1();
test2();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +0,0 @@
include ..\..\makefile.i
doall: tsos tsosaux
tsos: ..\os.lib tsos.c
$(CCOM) $(CFL) -I.. -I..\.. ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\os.lib tsos.c $(LFL)
tsosaux: tsosaux.c
$(CCOM) $(CFL) -I.. -I..\.. ..\..\ut.lib ..\os.lib tsosaux.c $(LFL)

View File

@ -1,793 +0,0 @@
/************************************************************************
The test module for the operating system interface
(c) 1995 Innobase Oy
Created 9/27/1995 Heikki Tuuri
*************************************************************************/
#include "../os0thread.h"
#include "../os0shm.h"
#include "../os0proc.h"
#include "../os0sync.h"
#include "../os0file.h"
#include "ut0ut.h"
#include "ut0mem.h"
#include "sync0sync.h"
#include "mem0mem.h"
#define _WIN32_WINNT 0x0400
#include "n:\program files\devstudio\vc\include\windows.h"
#include "n:\program files\devstudio\vc\include\winbase.h"
ulint last_thr = 1;
byte global_buf[4000000];
ulint* cache_buf;
os_file_t file;
os_file_t file2;
os_event_t gl_ready;
mutex_t ios_mutex;
ulint ios;
ulint rnd = 9837497;
/********************************************************************
Start function for threads in test1. */
ulint
thread(void* arg)
/*==============*/
{
ulint i;
void* arg2;
ulint count = 0;
ulint n;
ulint rnd_loc;
byte local_buf[2000];
arg2 = arg;
n = *((ulint*)arg);
/* printf("Thread %lu started!\n", n); */
for (i = 0; i < 8000; i++) {
rnd_loc = rnd;
rnd += 763482469;
ut_memcpy(global_buf + (rnd_loc % 1500000) + 8200, local_buf,
2000);
if (last_thr != n) {
count++;
last_thr = n;
}
if (i % 32 == 0) {
os_thread_yield();
}
}
printf("Thread %lu exits: %lu thread switches noticed\n", n, count);
return(0);
}
/*********************************************************************
Test of the speed of wait for multiple events. */
void
testa1(void)
/*========*/
{
ulint i;
os_event_t arr[64];
ulint tm, oldtm;
printf("-------------------------------------------------\n");
printf("TEST A1. Speed of waits\n");
for (i = 0; i < 64; i++) {
arr[i] = os_event_create(NULL);
ut_a(arr[i]);
}
os_event_set(arr[1]);
oldtm = ut_clock();
for (i = 0; i < 10000; i++) {
os_event_wait_multiple(4, arr);
}
tm = ut_clock();
printf("Wall clock time for %lu multiple waits %lu millisecs\n",
i, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 10000; i++) {
os_event_wait(arr[1]);
}
tm = ut_clock();
printf("Wall clock time for %lu single waits %lu millisecs\n",
i, tm - oldtm);
for (i = 0; i < 64; i++) {
os_event_free(arr[i]);
}
}
/*********************************************************************
Test for threads. */
void
test1(void)
/*=======*/
{
os_thread_t thr[64];
os_thread_id_t id[64];
ulint n[64];
ulint tm, oldtm;
ulint i, j;
printf("-------------------------------------------\n");
printf("OS-TEST 1. Test of thread switching through yield\n");
printf("Main thread %lu starts!\n", os_thread_get_curr_id());
for (j = 0; j < 2; j++) {
oldtm = ut_clock();
for (i = 0; i < 64; i++) {
n[i] = i;
thr[i] = os_thread_create(thread, n + i, id + i);
/* printf("Thread %lu created, id %lu \n", i, id[i]); */
}
for (i = 0; i < 64; i++) {
os_thread_wait(thr[i]);
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 64; i++) {
thr[5] = os_thread_create(thread, n + 5, id + 5);
/* printf("Thread created, id %lu \n", id[5]); */
os_thread_wait(thr[5]);
}
tm = ut_clock();
printf("Wall clock time for single thread test %lu milliseconds\n",
tm - oldtm);
}
}
/*********************************************************************
Test for shared memory and process switching through yield. */
void
test2(void)
/*=======*/
{
os_shm_t shm;
ulint tm, oldtm;
ulint* pr_no;
ulint count;
ulint i;
bool ret;
os_process_t proc;
os_process_id_t proc_id;
printf("-------------------------------------------\n");
printf("OS-TEST 2. Test of process switching through yield\n");
shm = os_shm_create(1000, "TSOS_SHM");
pr_no = os_shm_map(shm);
*pr_no = 1;
count = 0;
ret = os_process_create("tsosaux.exe", NULL, &proc, &proc_id);
printf("Last error: %lu\n", os_thread_get_last_error());
ut_a(ret);
printf("Process 1 starts test!\n");
oldtm = ut_clock();
for (i = 0; i < 500000; i++) {
if (*pr_no != 1) {
count++;
*pr_no = 1;
}
os_thread_yield();
}
tm = ut_clock();
printf("Process 1 finishes test: %lu process switches noticed\n",
count);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_shm_unmap(shm);
os_shm_free(shm);
}
#ifdef notdefined
/*********************************************************************
Test for asynchronous file io. */
void
test3(void)
/*=======*/
{
ulint i;
ulint j;
void* mess;
bool ret;
void* buf;
ulint rnd;
ulint addr[64];
ulint serv[64];
ulint tm, oldtm;
printf("-------------------------------------------\n");
printf("OS-TEST 3. Test of asynchronous file io\n");
/* Align the buffer for file io */
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
rnd = ut_time();
rnd = rnd * 3416133;
printf("rnd seed %lu\n", rnd % 4900);
oldtm = ut_clock();
for (i = 0; i < 32; i++) {
ret = os_aio_read(file, buf, 8192 * (rnd % 4900), 0,
8192, (void*)i);
ut_a(ret);
rnd += 1;
ret = os_aio_wait(0, &mess);
ut_a(ret);
}
tm = ut_clock();
printf("Wall clock time for synchr. io %lu milliseconds\n",
tm - oldtm);
rnd = rnd * 3416133;
printf("rnd seed %lu\n", rnd % 5000);
oldtm = ut_clock();
for (j = 0; j < 5; j++) {
rnd = rnd + 3416133;
for (i = 0; i < 16; i++) {
ret = os_aio_read(file, buf, 8192 * (rnd % 5000), 0, 8192,
(void*)i);
addr[i] = rnd % 5000;
ut_a(ret);
rnd += 1;
}
for (i = 0; i < 16; i++) {
ret = os_aio_read(file, buf, 8192 * (rnd % 5000), 0, 8192,
(void*)i);
addr[i] = rnd % 5000;
ut_a(ret);
rnd += 1;
}
rnd = rnd + 3416133;
for (i = 0; i < 32; i++) {
ret = os_aio_wait(0, &mess);
ut_a(ret);
ut_a((ulint)mess < 64);
serv[(ulint)mess] = i;
}
}
tm = ut_clock();
printf("Wall clock time for aio %lu milliseconds\n", tm - oldtm);
rnd = rnd * 3416133;
printf("rnd seed %lu\n", rnd % 4900);
oldtm = ut_clock();
for (j = 0; j < 5; j++) {
rnd = rnd + 3416133;
for (i = 0; i < 1; i++) {
ret = os_aio_read(file, buf, 8192 * (rnd % 4900), 0,
64 * 8192, (void*)i);
ut_a(ret);
rnd += 4;
ret = os_aio_wait(0, &mess);
ut_a(ret);
ut_a((ulint)mess < 64);
}
}
tm = ut_clock();
printf("Wall clock time for synchr. io %lu milliseconds\n",
tm - oldtm);
/*
for (i = 0; i < 63; i++) {
printf("read %lu addr %lu served as %lu\n",
i, addr[i], serv[i]);
}
*/
ut_a(ret);
}
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = os_aio_wait(segment, &mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
ut_a(ret);
/* printf("Message for thread %lu %lu\n", segment,
(ulint)mess); */
if ((ulint)mess == 3333) {
os_event_set(gl_ready);
}
}
return(0);
}
/************************************************************************
Test of io-handler threads */
void
test4(void)
/*=======*/
{
ulint i;
ulint j;
bool ret;
void* buf;
ulint rnd;
ulint tm, oldtm;
os_thread_t thr[5];
os_thread_id_t id[5];
ulint n[5];
printf("-------------------------------------------\n");
printf("OS-TEST 4. Test of asynchronous file io\n");
/* Align the buffer for file io */
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
gl_ready = os_event_create(NULL);
ios = 0;
sync_init();
mem_init();
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
rnd = 0;
oldtm = ut_clock();
for (j = 0; j < 128; j++) {
for (i = 0; i < 32; i++) {
ret = os_aio_read(file, (byte*)buf + 8192 * (rnd % 100),
8192 * (rnd % 4096), 0,
8192, (void*)i);
ut_a(ret);
rnd += 1;
}
/*
rnd += 67475941;
for (i = 0; i < 1; i++) {
ret = os_aio_read(file2, buf, 8192 * (rnd % 5000), 0,
8192, (void*)i);
ut_a(ret);
rnd += 1;
}
*/
}
ret = os_aio_read(file, buf, 8192 * (rnd % 4096), 0, 8192,
(void*)3333);
ut_a(ret);
ut_a(!os_aio_all_slots_free());
/*
printf("Starting flush!\n");
ret = os_file_flush(file);
ut_a(ret);
printf("Ending flush!\n");
*/
tm = ut_clock();
printf("All ios queued! N ios: %lu\n", ios);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_event_wait(gl_ready);
tm = ut_clock();
printf("N ios: %lu\n", ios);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_thread_sleep(2000000);
printf("N ios: %lu\n", ios);
ut_a(os_aio_all_slots_free());
}
/*************************************************************************
Initializes the asyncronous io system for tests. */
void
init_aio(void)
/*==========*/
{
bool ret;
ulint i;
void* buf;
void* mess;
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
os_aio_init(160, 5);
file = os_file_create("j:\\tsfile2", OS_FILE_CREATE, OS_FILE_TABLESPACE,
&ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() == OS_FILE_ALREADY_EXISTS);
file = os_file_create("j:\\tsfile2", OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
} else {
for (i = 0; i < 4100; i++) {
ret = os_aio_write(file, buf, 8192 * i, 0, 8192, NULL);
ut_a(ret);
ret = os_aio_wait(0, &mess);
ut_a(ret);
ut_a(mess == NULL);
}
}
file2 = os_file_create("F:\\tmp\\tsfile", OS_FILE_CREATE,
OS_FILE_TABLESPACE,
&ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() == OS_FILE_ALREADY_EXISTS);
file2 = os_file_create("F:\\tmp\\tsfile", OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
} else {
for (i = 0; i < 5000; i++) {
ret = os_aio_write(file2, buf, 8192 * i, 0, 8192, NULL);
ut_a(ret);
ret = os_aio_wait(0, &mess);
ut_a(ret);
ut_a(mess == NULL);
}
}
}
/************************************************************************
Test of synchronous io */
void
test5(void)
/*=======*/
{
ulint i, j, k;
bool ret;
void* buf;
ulint rnd = 0;
ulint tm = 0;
ulint oldtm = 0;
os_file_t files[1000];
char name[5];
ulint err;
printf("-------------------------------------------\n");
printf("OS-TEST 5. Test of creating and opening of many files\n");
/* Align the buffer for file io */
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
name[2] = '.';
name[3] = 'd';
name[4] = '\0';
oldtm = ut_clock();
for (j = 0; j < 20; j++) {
for (i = 0; i < 20; i++) {
name[0] = (char)(i + (ulint)'A');
name[1] = (char)(j + (ulint)'A');
files[j * 20 + i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_NORMAL, &ret);
if (!ret) {
err = os_file_get_last_error();
}
ut_a(ret);
}
}
for (k = 0; k < i * j; k++) {
ret = os_file_close(files[k]);
ut_a(ret);
}
for (j = 0; j < 20; j++) {
for (i = 0; i < 20; i++) {
name[0] = (char)(i + (ulint)'A');
name[1] = (char)(j + (ulint)'A');
ret = os_file_delete(name);
ut_a(ret);
}
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
}
/************************************************************************
Test of synchronous io */
void
test6(void)
/*=======*/
{
ulint i, j;
bool ret;
void* buf;
ulint rnd = 0;
ulint tm = 0;
ulint oldtm = 0;
os_file_t s_file;
printf("-------------------------------------------\n");
printf("OS-TEST 6. Test of synchronous io\n");
buf = (void*)(((ulint)global_buf + 6300) & (~0xFFF));
ret = os_file_close(file);
ut_a(ret);
ret = os_file_close(file2);
ut_a(ret);
s_file = os_file_create("tsfile", OS_FILE_OPEN,
OS_FILE_NORMAL, &ret);
if (!ret) {
printf("Error no %lu\n", os_file_get_last_error());
}
ut_a(ret);
rnd = ut_time() * 6346353;
oldtm = ut_clock();
for (j = 0; j < 100; j++) {
rnd += 8072791;
for (i = 0; i < 32; i++) {
ret = os_file_read(s_file, buf, 8192 * (rnd % 5000), 0,
8192);
ut_a(ret);
rnd += 1;
}
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
}
/************************************************************************
Test of file size operations. */
void
test7(void)
/*=======*/
{
bool ret;
os_file_t f;
ulint len;
ulint high;
printf("-------------------------------------------\n");
printf("OS-TEST 7. Test of setting and getting file size\n");
f = os_file_create("sizefile", OS_FILE_CREATE, OS_FILE_TABLESPACE,
&ret);
ut_a(ret);
ret = os_file_get_size(f, &len, &high);
ut_a(ret);
ut_a(len == 0);
ut_a(high == 0);
ret = os_file_set_size(f, 5000000, 0);
ut_a(ret);
ret = os_file_get_size(f, &len, &high);
ut_a(ret);
ut_a(len == 5000000);
ut_a(high == 0);
ret = os_file_set_size(f, 4000000, 0);
ut_a(ret);
ret = os_file_get_size(f, &len, &high);
ut_a(ret);
ut_a(len == 4000000);
ut_a(high == 0);
ret = os_file_close(f);
ut_a(ret);
ret = os_file_delete("sizefile");
ut_a(ret);
}
#endif
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
ulint i;
CRITICAL_SECTION cs;
ulint sum;
ulint rnd;
cache_buf = VirtualAlloc(NULL, 4 * 1024, MEM_COMMIT,
PAGE_READWRITE /* | PAGE_NOCACHE */);
oldtm = ut_clock();
sum = 0;
rnd = 0;
for (i = 0; i < 1000000; i++) {
sum += cache_buf[rnd * (16)];
rnd += 1;
if (rnd > 7) {
rnd = 0;
}
}
tm = ut_clock();
printf("Wall clock time for cache test %lu milliseconds\n", tm - oldtm);
InterlockedExchange(&i, 5);
InitializeCriticalSection(&cs);
oldtm = ut_clock();
for (i = 0; i < 10000000; i++) {
TryEnterCriticalSection(&cs);
LeaveCriticalSection(&cs);
}
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
testa1();
test1();
/* test2(); */
/* init_aio(); */
/*
test3();
*/
/* test4();
test5();
test6();
test7(); */
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,83 +0,0 @@
/************************************************************************
The test module for the operating system interface
Auxiliary executable run alongside tsos.exe to test
process switching speed
(c) 1995 Innobase Oy
Created 9/27/1995 Heikki Tuuri
*************************************************************************/
#include "../os0thread.h"
#include "../os0shm.h"
#include "../os0proc.h"
#include "ut0ut.h"
/*********************************************************************
Test for shared memory and process switching through yield. */
void
test2(void)
/*=======*/
{
os_shm_t shm;
ulint tm, oldtm;
ulint* pr_no;
ulint count;
ulint i;
printf("-------------------------------------------\n");
printf("OS-TEST 2. Test of process switching through yield\n");
shm = os_shm_create(1000, "TSOS_SHM");
pr_no = os_shm_map(shm);
count = 0;
printf("Process 2 starts test!\n");
oldtm = ut_clock();
for (i = 0; i < 100000; i++) {
if (*pr_no != 2) {
count++;
*pr_no = 2;
}
os_thread_yield();
}
tm = ut_clock();
printf("Process 2 finishes test: %lu process switches noticed\n",
count);
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
os_shm_unmap(shm);
os_shm_free(shm);
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
oldtm = ut_clock();
test2();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
os_process_exit(0);
}

View File

@ -1,16 +0,0 @@
include ..\..\makefile.i
tspage: ..\page.lib tspage.c
$(CCOM) $(CFL) -I.. -I..\.. ..\page.lib ..\..\btr.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tspage.c $(LFL)

View File

@ -1,705 +0,0 @@
/************************************************************************
The test for the index page
(c) 1994-1996 Innobase Oy
Created 1/31/1994 Heikki Tuuri
*************************************************************************/
#include "sync0sync.h"
#include "ut0mem.h"
#include "mem0mem.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "buf0buf.h"
#include "os0file.h"
#include "fil0fil.h"
#include "rem0rec.h"
#include "rem0cmp.h"
#include "mtr0mtr.h"
#include "log0log.h"
#include "..\page0page.h"
#include "..\page0cur.h"
os_file_t files[1000];
mutex_t ios_mutex;
ulint ios;
ulint n[10];
mutex_t incs_mutex;
ulint incs;
byte bigbuf[1000000];
#define N_SPACES 1
#define N_FILES 2
#define FILE_SIZE 1000 /* must be > 512 */
#define POOL_SIZE 1000
#define COUNTER_OFFSET 1500
#define LOOP_SIZE 150
#define N_THREADS 5
ulint zero = 0;
buf_block_t* bl_arr[POOL_SIZE];
/************************************************************************
Io-handler thread function. */
ulint
handler_thread(
/*===========*/
void* arg)
{
ulint segment;
void* mess;
ulint i;
bool ret;
segment = *((ulint*)arg);
printf("Io handler thread %lu starts\n", segment);
for (i = 0;; i++) {
ret = fil_aio_wait(segment, &mess);
ut_a(ret);
buf_page_io_complete((buf_block_t*)mess);
mutex_enter(&ios_mutex);
ios++;
mutex_exit(&ios_mutex);
}
return(0);
}
/*************************************************************************
Creates the files for the file system test and inserts them to
the file system. */
void
create_files(void)
/*==============*/
{
bool ret;
ulint i, k;
char name[20];
os_thread_t thr[5];
os_thread_id_t id[5];
printf("--------------------------------------------------------\n");
printf("Create or open database files\n");
strcpy(name, "j:\\tsfile00");
for (k = 0; k < N_SPACES; k++) {
for (i = 0; i < N_FILES; i++) {
name[9] = (char)((ulint)'0' + k);
name[10] = (char)((ulint)'0' + i);
files[i] = os_file_create(name, OS_FILE_CREATE,
OS_FILE_TABLESPACE, &ret);
if (ret == FALSE) {
ut_a(os_file_get_last_error() ==
OS_FILE_ALREADY_EXISTS);
files[i] = os_file_create(
name, OS_FILE_OPEN,
OS_FILE_TABLESPACE, &ret);
ut_a(ret);
}
ret = os_file_close(files[i]);
ut_a(ret);
if (i == 0) {
fil_space_create(name, k, OS_FILE_TABLESPACE);
}
ut_a(fil_validate());
fil_node_create(name, FILE_SIZE, k);
}
}
ios = 0;
mutex_create(&ios_mutex);
for (i = 0; i < 5; i++) {
n[i] = i;
thr[i] = os_thread_create(handler_thread, n + i, id + i);
}
}
/*********************************************************************
Test for index page. */
void
test1(void)
/*=======*/
{
page_t* page;
dtuple_t* tuple;
mem_heap_t* heap;
ulint i;
ulint rnd = 0;
rec_t* rec;
page_cur_t cursor;
dict_index_t* index;
dict_table_t* table;
buf_block_t* block;
buf_frame_t* frame;
mtr_t mtr;
printf("-------------------------------------------------\n");
printf("TEST 1. Basic test\n");
heap = mem_heap_create(0);
table = dict_table_create("TS_TABLE1", 3);
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_table_add_col(table, "COL3", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
ut_a(0 == dict_table_publish(table));
index = dict_index_create("TS_TABLE1", "IND1", 0, 3, 0);
dict_index_add_field(index, "COL1", 0);
dict_index_add_field(index, "COL2", 0);
dict_index_add_field(index, "COL3", 0);
ut_a(0 == dict_index_publish(index));
index = dict_index_get("TS_TABLE1", "IND1");
ut_a(index);
tuple = dtuple_create(heap, 3);
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
for (i = 0; i < 512; i++) {
rnd = (rnd + 534671) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
/* page_print_list(page, 151); */
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 512);
for (i = 0; i < 512; i++) {
rnd = (rnd + 7771) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_get_n_recs(page) == 0);
ut_a(page_validate(page, index));
page = page_create(frame, &mtr);
rnd = 311;
for (i = 0; i < 512; i++) {
rnd = (rnd + 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 512);
rnd = 217;
for (i = 0; i < 512; i++) {
rnd = (rnd + 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 0);
page = page_create(frame, &mtr);
rnd = 291;
for (i = 0; i < 512; i++) {
rnd = (rnd - 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 512);
rnd = 277;
for (i = 0; i < 512; i++) {
rnd = (rnd - 1) % 512;
if (i % 27 == 0) {
ut_a(page_validate(page, index));
}
dtuple_gen_test_tuple(tuple, rnd);
/* dtuple_print(tuple);*/
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
ut_a(rec);
rec_validate(rec);
/* page_print_list(page, 151); */
}
ut_a(page_validate(page, index));
ut_a(page_get_n_recs(page) == 0);
mtr_commit(&mtr);
mem_heap_free(heap);
}
/*********************************************************************
Test for index page. */
void
test2(void)
/*=======*/
{
page_t* page;
dtuple_t* tuple;
mem_heap_t* heap;
ulint i, j;
ulint rnd = 0;
rec_t* rec;
page_cur_t cursor;
dict_index_t* index;
dict_table_t* table;
buf_block_t* block;
buf_frame_t* frame;
ulint tm, oldtm;
byte buf[8];
mtr_t mtr;
mtr_t mtr2;
printf("-------------------------------------------------\n");
printf("TEST 2. Speed test\n");
oldtm = ut_clock();
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
ut_memcpy(bigbuf, bigbuf + 800, 800);
}
tm = ut_clock();
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
i, tm - oldtm);
oldtm = ut_clock();
rnd = 0;
for (i = 0; i < 1000 * UNIV_DBC * UNIV_DBC; i++) {
ut_memcpy(bigbuf + rnd, bigbuf + rnd + 800, 800);
rnd += 1600;
if (rnd > 995000) {
rnd = 0;
}
}
tm = ut_clock();
printf("Wall time for %lu mem copys of 800 bytes %lu millisecs\n",
i, tm - oldtm);
heap = mem_heap_create(0);
table = dict_table_create("TS_TABLE2", 2);
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
ut_a(0 == dict_table_publish(table));
index = dict_index_create("TS_TABLE2", "IND2", 0, 2, 0);
dict_index_add_field(index, "COL1", 0);
dict_index_add_field(index, "COL2", 0);
ut_a(0 == dict_index_publish(index));
index = dict_index_get("TS_TABLE2", "IND2");
ut_a(index);
tuple = dtuple_create(heap, 3);
oldtm = ut_clock();
rnd = 677;
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
for (j = 0; j < 200; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall time for insertion of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
mtr_start(&mtr);
block = buf_page_get(0, 5, &mtr);
buf_page_s_lock(block, &mtr);
page = buf_block_get_frame(block);
ut_a(page_validate(page, index));
mtr_commit(&mtr);
oldtm = ut_clock();
rnd = 677;
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
for (j = 0; j < 200; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf(
"Wall time for %lu empty loops with page create %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
mtr_commit(&mtr);
rnd = 100;
for (j = 0; j < 200; j++) {
mtr_start(&mtr2);
block = buf_page_get(0, 5, &mtr2);
buf_page_x_lock(block, &mtr2);
page = buf_block_get_frame(block);
rnd = (rnd + 1) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr2);
ut_a(rec);
mtr_commit(&mtr2);
}
}
tm = ut_clock();
printf(
"Wall time for sequential insertion of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
mtr_start(&mtr);
block = buf_page_get(0, 5, &mtr);
buf_page_s_lock(block, &mtr);
page = buf_block_get_frame(block);
ut_a(page_validate(page, index));
mtr_commit(&mtr);
oldtm = ut_clock();
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
rnd = 500;
for (j = 0; j < 200; j++) {
rnd = (rnd - 1) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
mtr_commit(&mtr);
}
tm = ut_clock();
printf(
"Wall time for descend. seq. insertion of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
rnd = 677;
for (j = 0; j < 200; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
rnd = 677;
for (j = 0; j < 200; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
page_cur_delete_rec(&cursor, &mtr);
}
ut_a(page_get_n_recs(page) == 0);
mtr_commit(&mtr);
}
tm = ut_clock();
printf("Wall time for insert and delete of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
mtr_start(&mtr);
block = buf_page_create(0, 5, &mtr);
buf_page_x_lock(block, &mtr);
frame = buf_block_get_frame(block);
page = page_create(frame, &mtr);
rnd = 677;
for (j = 0; j < 200; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
rec = page_cur_insert_rec(&cursor, tuple, NULL, &mtr);
ut_a(rec);
}
ut_a(page_validate(page, index));
mtr_print(&mtr);
oldtm = ut_clock();
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
rnd = 677;
for (j = 0; j < 200; j++) {
/* rnd = (rnd + 54841) % 1000;*/
dtuple_gen_test_tuple3(tuple, rnd, buf);
page_cur_search(page, tuple, PAGE_CUR_G, &cursor);
}
}
tm = ut_clock();
printf("Wall time for search of %lu recs %lu milliseconds\n",
i * j, tm - oldtm);
oldtm = ut_clock();
for (i = 0; i < 5 * UNIV_DBC * UNIV_DBC; i++) {
rnd = 677;
for (j = 0; j < 200; j++) {
rnd = (rnd + 54841) % 1000;
dtuple_gen_test_tuple3(tuple, rnd, buf);
}
}
tm = ut_clock();
printf("Wall time for %lu empty loops %lu milliseconds\n",
i * j, tm - oldtm);
mtr_commit(&mtr);
}
/********************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
sync_init();
mem_init();
os_aio_init(160, 5);
fil_init(25);
buf_pool_init(100, 100);
dict_init();
log_init();
create_files();
oldtm = ut_clock();
ut_rnd_set_seed(19);
test1();
test2();
mem_print_info();
tm = ut_clock();
printf("Wall time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -7,7 +7,7 @@ Created 5/27/1996 Heikki Tuuri
*******************************************************/ *******************************************************/
#include "que0que.h" #include "que0que.h"
#ifdef UNIV_NONINL #ifdef UNIV_NONINL
#include "que0que.ic" #include "que0que.ic"
#endif #endif

View File

@ -1,16 +0,0 @@
include ..\..\makefile.i
tsrem: ..\rem.lib tsrem.c
$(CCOM) $(CFL) -I.. -I..\.. ..\rem.lib ..\..\page.lib ..\..\mtr.lib ..\..\btr.lib ..\..\log.lib ..\..\dyn.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tsrem.c $(LFL)

View File

@ -1,464 +0,0 @@
/************************************************************************
The test for the record manager
(c) 1994-1996 Innobase Oy
Created 1/25/1994 Heikki Tuuri
*************************************************************************/
#include "sync0sync.h"
#include "mem0mem.h"
#include "data0data.h"
#include "data0type.h"
#include "dict0dict.h"
#include "buf0buf.h"
#include "fil0fil.h"
#include "../rem0rec.h"
#include "../rem0cmp.h"
byte buf1[100000];
/*********************************************************************
Test for data tuples. */
void
test1(void)
/*=======*/
{
dtype_t* type;
dtuple_t* tuple, *tuple2;
dfield_t* field;
mem_heap_t* heap;
ulint i, j;
ulint n;
char* p_Pascal;
char* p_Cobol;
heap = mem_heap_create(0);
printf("-------------------------------------------\n");
printf("DATA TUPLE-TEST 1. Basic tests.\n");
tuple = dtuple_create(heap, 2);
field = dtuple_get_nth_field(tuple, 0);
dfield_set_data(field, "Pascal", 7);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
field = dtuple_get_nth_field(tuple, 1);
dfield_set_data(field, "Cobol", 6);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
dtuple_validate(tuple);
dtuple_print(tuple);
tuple2 = dtuple_create(heap, 10);
for (i = 0; i < 10; i++) {
field = dtuple_get_nth_field(tuple2, i);
dfield_set_data(field, NULL, UNIV_SQL_NULL);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH,
6, 0);
}
dtuple_print(tuple2);
printf("-------------------------------------------\n");
printf("DATA TUPLE-TEST 2. Accessor function tests.\n");
tuple = dtuple_create(heap, 2);
p_Pascal = "Pascal";
p_Cobol = "Cobol";
field = dtuple_get_nth_field(tuple, 0);
dfield_set_data(field, p_Pascal, 7);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
field = dtuple_get_nth_field(tuple, 1);
dfield_set_data(field, p_Cobol, 6);
dtype_set(dfield_get_type(field), DATA_VARCHAR, DATA_ENGLISH, 16, 3);
ut_a(dtuple_get_n_fields(tuple) == 2);
field = dtuple_get_nth_field(tuple, 0);
ut_a(p_Pascal == dfield_get_data(field));
ut_a(7 == dfield_get_len(field));
type = dfield_get_type(field);
ut_a(type->mtype == DATA_CHAR);
ut_a(type->prtype == DATA_ENGLISH);
ut_a(type->len == 7);
ut_a(type->prec == 0);
field = dtuple_get_nth_field(tuple, 1);
ut_a(p_Cobol == dfield_get_data(field));
ut_a(6 == dfield_get_len(field));
type = dfield_get_type(field);
ut_a(type->mtype == DATA_VARCHAR);
ut_a(type->prtype == DATA_ENGLISH);
ut_a(type->len == 16);
ut_a(type->prec == 3);
printf("-------------------------------------------\n");
printf("DATA TYPE-TEST 3. Other function tests\n");
ut_a(dtuple_get_data_size(tuple) == 13);
ut_a(dtuple_fold(tuple, 2) == dtuple_fold(tuple, 2));
ut_a(dtuple_fold(tuple, 1) != dtuple_fold(tuple, 2));
printf("-------------------------------------------\n");
printf("DATA TUPLE-TEST 4. Random tuple generation test\n");
for (i = 0; i < 500; i++) {
tuple = dtuple_gen_rnd_tuple(heap);
printf("%lu ", i);
dtuple_validate(tuple);
n = dtuple_get_n_fields(tuple);
if (n < 25) {
tuple2 = dtuple_create(heap, n);
for (j = 0; j < n; j++) {
dfield_copy(
dtuple_get_nth_field(tuple2, j),
dtuple_get_nth_field(tuple, j));
}
dtuple_validate(tuple2);
ut_a(dtuple_fold(tuple, n) ==
dtuple_fold(tuple2, n));
}
}
mem_print_info();
mem_heap_free(heap);
}
/**********************************************************************
Test for physical records. */
void
test2(void)
/*=======*/
{
dtuple_t* tuple, *tuple2;
dfield_t* field;
mem_heap_t* heap;
ulint i, n;
char* p_Pascal;
char* p_Cobol;
rec_t* rec, *rec2;
byte* data;
ulint len;
byte* buf;
heap = mem_heap_create(0);
printf("-------------------------------------------\n");
printf("REC-TEST 1. Basic tests.\n");
tuple = dtuple_create(heap, 2);
p_Pascal = "Pascal";
p_Cobol = "Cobol";
field = dtuple_get_nth_field(tuple, 0);
dfield_set_data(field, "Pascal", 7);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
field = dtuple_get_nth_field(tuple, 1);
dfield_set_data(field, "Cobol", 6);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
tuple2 = dtuple_create(heap, 37);
for (i = 0; i < 37; i++) {
field = dtuple_get_nth_field(tuple2, i);
dfield_set_data(field, NULL, UNIV_SQL_NULL);
dtype_set(dfield_get_type(field), DATA_CHAR,
DATA_ENGLISH, 6, 0);
}
rec = rec_convert_dtuple_to_rec(buf1, tuple);
rec_validate(rec);
rec_print(rec);
rec2 = rec_convert_dtuple_to_rec(buf1 + 1000, tuple2);
rec_validate(rec2);
data = rec_get_nth_field(rec, 0, &len);
ut_a(0 == memcmp(p_Pascal, data, 7));
ut_a(len == 7);
data = rec_get_nth_field(rec, 1, &len);
ut_a(0 == memcmp(p_Cobol, data, 6));
ut_a(len == 6);
ut_a(2 == rec_get_n_fields(rec));
for (i = 0; i < 37; i++) {
data = rec_get_nth_field(rec2, i, &len);
ut_a(len == UNIV_SQL_NULL);
}
printf("-------------------------------------------\n");
printf("REC-TEST 2. Test of accessor functions\n");
rec_set_next_offs(rec, 8190);
rec_set_n_owned(rec, 15);
rec_set_heap_no(rec, 0);
ut_a(rec_get_next_offs(rec) == 8190);
ut_a(rec_get_n_owned(rec) == 15);
ut_a(rec_get_heap_no(rec) == 0);
rec_set_next_offs(rec, 1);
rec_set_n_owned(rec, 1);
rec_set_heap_no(rec, 8190);
ut_a(rec_get_next_offs(rec) == 1);
ut_a(rec_get_n_owned(rec) == 1);
ut_a(rec_get_heap_no(rec) == 8190);
buf = mem_heap_alloc(heap, 6);
rec_copy_nth_field(buf, rec, 1, &len);
ut_a(ut_memcmp(p_Cobol, buf, len) == 0);
ut_a(len == 6);
rec_set_nth_field(rec, 1, "Algol", 6);
rec_validate(rec);
rec_copy_nth_field(buf, rec, 1, &len);
ut_a(ut_memcmp("Algol", buf, len) == 0);
ut_a(len == 6);
ut_a(rec_get_data_size(rec) == 13);
ut_a((ulint)(rec_get_end(rec) - rec) == 13);
ut_a(14 == (ulint)(rec - rec_get_start(rec)));
ut_a(rec_get_size(rec) == 27);
mem_heap_free(heap);
printf("-------------------------------------------\n");
printf("REC-TEST 3. Massive test of conversions \n");
heap = mem_heap_create(0);
for (i = 0; i < 100; i++) {
tuple = dtuple_gen_rnd_tuple(heap);
if (i % 10 == 0) {
printf("%lu ", i);
}
if (i % 10 == 0) {
printf(
"data tuple generated: %lu fields, data size %lu\n",
dtuple_get_n_fields(tuple),
dtuple_get_data_size(tuple));
}
dtuple_validate(tuple);
rec = rec_convert_dtuple_to_rec(buf1, tuple);
rec_validate(rec);
n = dtuple_get_n_fields(tuple);
ut_a(cmp_dtuple_rec_prefix_equal(tuple, rec, n));
ut_a(dtuple_fold(tuple, n) == rec_fold(rec, n));
ut_a(rec_get_converted_size(tuple) == rec_get_size(rec));
ut_a(rec_get_data_size(rec) == dtuple_get_data_size(tuple));
}
mem_print_info();
mem_heap_free(heap);
}
/**********************************************************************
Test for comparisons. */
void
test3(void)
/*=======*/
{
dtuple_t* tuple, *tuple2, *tuple3;
dfield_t* field;
mem_heap_t* heap;
ulint i, j;
ulint field_match, byte_match;
rec_t* rec;
rec_t* rec2;
ulint tm, oldtm;
dict_index_t* index;
dict_table_t* table;
heap = mem_heap_create(0);
printf("-------------------------------------------\n");
printf("CMP-TEST 1. Basic tests.\n");
tuple = dtuple_create(heap, 2);
field = dtuple_get_nth_field(tuple, 0);
dfield_set_data(field, "Pascal", 7);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
field = dtuple_get_nth_field(tuple, 1);
dfield_set_data(field, "Cobol", 6);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
tuple2 = dtuple_create(heap, 2);
field = dtuple_get_nth_field(tuple2, 0);
dfield_set_data(field, "Pascal", 7);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
field = dtuple_get_nth_field(tuple2, 1);
dfield_set_data(field, "Cobom", 6);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
tuple3 = dtuple_create(heap, 2);
field = dtuple_get_nth_field(tuple3, 0);
dfield_set_data(field, "PaSCal", 7);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 7, 0);
field = dtuple_get_nth_field(tuple3, 1);
dfield_set_data(field, "CobOL", 6);
dtype_set(dfield_get_type(field), DATA_CHAR, DATA_ENGLISH, 6, 0);
rec = rec_convert_dtuple_to_rec(buf1, tuple);
rec_validate(rec);
ut_a(!cmp_dtuple_rec_prefix_equal(tuple2, rec, 2));
ut_a(cmp_dtuple_rec_prefix_equal(tuple, rec, 2));
ut_a(cmp_dtuple_rec_prefix_equal(tuple3, rec, 2));
oldtm = ut_clock();
j = 0;
for (i = 0; i < 1000; i++) {
field_match = 1;
byte_match = 4;
if (1 == cmp_dtuple_rec_with_match(tuple2, rec,
&field_match, &byte_match)) {
j++;
}
}
tm = ut_clock();
printf("Time for fast comp. %lu records = %lu\n", j, tm - oldtm);
ut_a(field_match == 1);
ut_a(byte_match == 4);
oldtm = ut_clock();
j = 0;
for (i = 0; i < 1000; i++) {
field_match = 0;
byte_match = 0;
if (1 == cmp_dtuple_rec_with_match(tuple2, rec,
&field_match, &byte_match)) {
j++;
}
}
tm = ut_clock();
printf("Time for test comp. %lu records = %lu\n", j, tm - oldtm);
ut_a(field_match == 1);
ut_a(byte_match == 4);
printf("-------------------------------------------\n");
printf(
"CMP-TEST 2. A systematic test of comparisons and conversions\n");
tuple = dtuple_create(heap, 3);
tuple2 = dtuple_create(heap, 3);
table = dict_table_create("TS_TABLE1", 3);
dict_table_add_col(table, "COL1", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_table_add_col(table, "COL2", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
dict_table_add_col(table, "COL3", DATA_VARCHAR, DATA_ENGLISH, 10, 0);
ut_a(0 == dict_table_publish(table));
index = dict_index_create("TS_TABLE1", "IND1", 0, 3, 0);
dict_index_add_field(index, "COL1", 0);
dict_index_add_field(index, "COL2", 0);
dict_index_add_field(index, "COL3", 0);
ut_a(0 == dict_index_publish(index));
index = dict_index_get("TS_TABLE1", "IND1");
ut_a(index);
/* Compare all test data tuples to each other */
for (i = 0; i < 512; i++) {
dtuple_gen_test_tuple(tuple, i);
rec = rec_convert_dtuple_to_rec(buf1, tuple);
ut_a(rec_validate(rec));
ut_a(0 == cmp_dtuple_rec(tuple, rec));
for (j = 0; j < 512; j++) {
dtuple_gen_test_tuple(tuple2, j);
ut_a(dtuple_validate(tuple2));
rec2 = rec_convert_dtuple_to_rec(buf1 + 500, tuple2);
if (j < i) {
ut_a(-1 == cmp_dtuple_rec(tuple2, rec));
ut_a(-1 == cmp_rec_rec(rec2, rec, index));
} else if (j == i) {
ut_a(0 == cmp_dtuple_rec(tuple2, rec));
ut_a(0 == cmp_rec_rec(rec2, rec, index));
} else if (j > i) {
ut_a(1 == cmp_dtuple_rec(tuple2, rec));
ut_a(1 == cmp_rec_rec(rec2, rec, index));
}
}
}
mem_heap_free(heap);
}
/********************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
sync_init();
mem_init();
fil_init(25);
buf_pool_init(100, 100);
dict_init();
oldtm = ut_clock();
ut_rnd_set_seed(19);
test1();
test2();
test3();
tm = ut_clock();
printf("CPU time for test %lu microseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,16 +0,0 @@
include ..\..\makefile.i
tstcur: ..\tcur.lib tstcur.c
$(CCOM) $(CFL) -I.. -I..\.. ..\tcur.lib ..\..\trx.lib ..\..\btr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tstcur.c $(LFL)

File diff suppressed because it is too large Load Diff

View File

@ -863,123 +863,6 @@ srv_release_max_if_no_queries(void)
mutex_exit(&kernel_mutex); mutex_exit(&kernel_mutex);
} }
#ifdef notdefined
/***********************************************************************
Releases one utility thread if no queries are active and
the high-water mark 2 for the utility is exceeded. */
static
void
srv_release_one_if_no_queries(void)
/*===============================*/
{
ulint m;
ulint type;
mutex_enter(&kernel_mutex);
if (srv_n_threads_active[SRV_COM] > 0) {
mutex_exit(&kernel_mutex);
return;
}
type = SRV_RECOVERY;
m = 1;
if ((srv_meter[type] > srv_meter_high_water2[type])
&& (srv_n_threads_active[type] < m)) {
srv_release_threads(type, m - srv_n_threads_active[type]);
printf("Releasing one background\n");
}
mutex_exit(&kernel_mutex);
}
/***********************************************************************
Decrements the utility meter by the value given and suspends the calling
thread, which must be an utility thread of the type given, if necessary. */
static
void
srv_decrement_meter(
/*================*/
ulint type, /* in: utility type */
ulint n) /* in: value to subtract from meter */
{
ulint opt;
os_event_t event;
mutex_enter(&kernel_mutex);
if (srv_meter[type] < n) {
srv_meter[type] = 0;
} else {
srv_meter[type] -= n;
}
opt = srv_max_n_utilities(type);
if (opt < srv_n_threads_active[type]) {
event = srv_suspend_thread();
mutex_exit(&kernel_mutex);
os_event_wait(event);
} else {
mutex_exit(&kernel_mutex);
}
}
#endif
/*************************************************************************
Implements the server console. */
ulint
srv_console(
/*========*/
/* out: return code, not used */
void* arg) /* in: argument, not used */
{
char command[256];
UT_NOT_USED(arg);
mutex_enter(&kernel_mutex);
srv_table_reserve_slot(SRV_CONSOLE);
mutex_exit(&kernel_mutex);
os_event_wait(srv_sys->operational);
for (;;) {
scanf("%s", command);
srv_inc_thread_count(SRV_CONSOLE);
if (command[0] == 'c') {
printf("Making checkpoint\n");
log_make_checkpoint_at(ut_dulint_max, TRUE);
printf("Checkpoint completed\n");
} else if (command[0] == 'd') {
srv_sim_disk_wait_pct = atoi(command + 1);
printf(
"Starting disk access simulation with pct %lu\n",
srv_sim_disk_wait_pct);
} else {
printf("\nNot supported!\n");
}
srv_dec_thread_count(SRV_CONSOLE);
}
return(0);
}
/************************************************************************* /*************************************************************************
Creates the first communication endpoint for the server. This Creates the first communication endpoint for the server. This
first call also initializes the com0com.* module. */ first call also initializes the com0com.* module. */
@ -1008,69 +891,6 @@ srv_communication_init(
ut_a(ret == 0); ut_a(ret == 0);
} }
#ifdef notdefined
/*************************************************************************
Implements the recovery utility. */
static
ulint
srv_recovery_thread(
/*================*/
/* out: return code, not used */
void* arg) /* in: not used */
{
ulint slot_no;
os_event_t event;
UT_NOT_USED(arg);
slot_no = srv_table_reserve_slot(SRV_RECOVERY);
os_event_wait(srv_sys->operational);
for (;;) {
/* Finish a possible recovery */
srv_inc_thread_count(SRV_RECOVERY);
/* recv_recovery_from_checkpoint_finish(); */
srv_dec_thread_count(SRV_RECOVERY);
mutex_enter(&kernel_mutex);
event = srv_suspend_thread();
mutex_exit(&kernel_mutex);
/* Wait for somebody to release this thread; (currently, this
should never be released) */
os_event_wait(event);
}
return(0);
}
/*************************************************************************
Implements the purge utility. */
ulint
srv_purge_thread(
/*=============*/
/* out: return code, not used */
void* arg) /* in: not used */
{
UT_NOT_USED(arg);
os_event_wait(srv_sys->operational);
for (;;) {
trx_purge();
}
return(0);
}
#endif /* notdefined */
/************************************************************************* /*************************************************************************
Creates the utility threads. */ Creates the utility threads. */
@ -1100,58 +920,6 @@ srv_create_utility_threads(void)
ut_a(thread); */ ut_a(thread); */
} }
#ifdef notdefined
/*************************************************************************
Implements the communication threads. */
static
ulint
srv_com_thread(
/*===========*/
/* out: return code; not used */
void* arg) /* in: not used */
{
byte* msg_buf;
byte* addr_buf;
ulint msg_len;
ulint addr_len;
ulint ret;
UT_NOT_USED(arg);
srv_table_reserve_slot(SRV_COM);
os_event_wait(srv_sys->operational);
msg_buf = mem_alloc(com_endpoint_get_max_size(srv_sys->endpoint));
addr_buf = mem_alloc(COM_MAX_ADDR_LEN);
for (;;) {
ret = com_recvfrom(srv_sys->endpoint, msg_buf,
com_endpoint_get_max_size(srv_sys->endpoint),
&msg_len, (char*)addr_buf, COM_MAX_ADDR_LEN,
&addr_len);
ut_a(ret == 0);
srv_inc_thread_count(SRV_COM);
sess_process_cli_msg(msg_buf, msg_len, addr_buf, addr_len);
/* srv_increment_meter(SRV_RECOVERY, 1); */
srv_dec_thread_count(SRV_COM);
/* Release one utility thread for each utility if
high water mark 2 is exceeded and there are no
active queries. This is done to utilize possible
quiet time in the server. */
srv_release_one_if_no_queries();
}
return(0);
}
#endif
/************************************************************************* /*************************************************************************
Creates the communication threads. */ Creates the communication threads. */
@ -1171,53 +939,6 @@ srv_create_com_threads(void)
} }
} }
#ifdef notdefined
/*************************************************************************
Implements the worker threads. */
static
ulint
srv_worker_thread(
/*==============*/
/* out: return code, not used */
void* arg) /* in: not used */
{
os_event_t event;
UT_NOT_USED(arg);
srv_table_reserve_slot(SRV_WORKER);
os_event_wait(srv_sys->operational);
for (;;) {
mutex_enter(&kernel_mutex);
event = srv_suspend_thread();
mutex_exit(&kernel_mutex);
/* Wait for somebody to release this thread */
os_event_wait(event);
srv_inc_thread_count(SRV_WORKER);
/* Check in the server task queue if there is work for this
thread, and do the work */
srv_que_task_queue_check();
srv_dec_thread_count(SRV_WORKER);
/* Release one utility thread for each utility if
high water mark 2 is exceeded and there are no
active queries. This is done to utilize possible
quiet time in the server. */
srv_release_one_if_no_queries();
}
return(0);
}
#endif
/************************************************************************* /*************************************************************************
Creates the worker threads. */ Creates the worker threads. */
@ -1238,404 +959,6 @@ srv_create_worker_threads(void)
} }
} }
#ifdef notdefined
/*************************************************************************
Reads a keyword and a value from a file. */
ulint
srv_read_init_val(
/*==============*/
/* out: DB_SUCCESS or error code */
FILE* initfile, /* in: file pointer */
char* keyword, /* in: keyword before value(s), or NULL if
no keyword read */
char* str_buf, /* in/out: buffer for a string value to read,
buffer size must be 10000 bytes, if NULL
then not read */
ulint* num_val, /* out: numerical value to read, if NULL
then not read */
ibool print_not_err) /* in: if TRUE, then we will not print
error messages to console */
{
ulint ret;
char scan_buf[10000];
if (keyword == NULL) {
goto skip_keyword;
}
ret = fscanf(initfile, "%9999s", scan_buf);
if (ret == 0 || ret == EOF || 0 != ut_strcmp(scan_buf, keyword)) {
if (print_not_err) {
return(DB_ERROR);
}
printf("Error in InnoDB booting: keyword %s not found\n",
keyword);
printf("from the initfile!\n");
return(DB_ERROR);
}
skip_keyword:
if (num_val == NULL && str_buf == NULL) {
return(DB_SUCCESS);
}
ret = fscanf(initfile, "%9999s", scan_buf);
if (ret == EOF || ret == 0) {
if (print_not_err) {
return(DB_ERROR);
}
printf(
"Error in InnoDB booting: could not read first value after %s\n",
keyword);
printf("from the initfile!\n");
return(DB_ERROR);
}
if (str_buf) {
ut_memcpy(str_buf, scan_buf, 10000);
printf("init keyword %s value %s read\n", keyword, str_buf);
if (!num_val) {
return(DB_SUCCESS);
}
ret = fscanf(initfile, "%9999s", scan_buf);
if (ret == EOF || ret == 0) {
if (print_not_err) {
return(DB_ERROR);
}
printf(
"Error in InnoDB booting: could not read second value after %s\n",
keyword);
printf("from the initfile!\n");
return(DB_ERROR);
}
}
if (ut_strlen(scan_buf) > 9) {
if (print_not_err) {
return(DB_ERROR);
}
printf(
"Error in InnoDB booting: numerical value too big after %s\n",
keyword);
printf("in the initfile!\n");
return(DB_ERROR);
}
*num_val = (ulint)atoi(scan_buf);
if (*num_val >= 1000000000) {
if (print_not_err) {
return(DB_ERROR);
}
printf(
"Error in InnoDB booting: numerical value too big after %s\n",
keyword);
printf("in the initfile!\n");
return(DB_ERROR);
}
printf("init keyword %s value %lu read\n", keyword, *num_val);
return(DB_SUCCESS);
}
/*************************************************************************
Reads keywords and values from an initfile. */
ulint
srv_read_initfile(
/*==============*/
/* out: DB_SUCCESS or error code */
FILE* initfile) /* in: file pointer */
{
char str_buf[10000];
ulint n;
ulint i;
ulint ulint_val;
ulint val1;
ulint val2;
ulint err;
err = srv_read_init_val(initfile, "INNOBASE_DATA_HOME_DIR",
str_buf, NULL, FALSE);
if (err != DB_SUCCESS) return(err);
srv_data_home = ut_malloc(ut_strlen(str_buf) + 1);
ut_memcpy(srv_data_home, str_buf, ut_strlen(str_buf) + 1);
err = srv_read_init_val(initfile,"TABLESPACE_NUMBER_OF_DATA_FILES",
NULL, &n, FALSE);
if (err != DB_SUCCESS) return(err);
srv_n_data_files = n;
srv_data_file_names = ut_malloc(n * sizeof(char*));
srv_data_file_sizes = ut_malloc(n * sizeof(ulint));
for (i = 0; i < n; i++) {
err = srv_read_init_val(initfile,
"DATA_FILE_PATH_AND_SIZE_MB",
str_buf, &ulint_val, FALSE);
if (err != DB_SUCCESS) return(err);
srv_data_file_names[i] = ut_malloc(ut_strlen(str_buf) + 1);
ut_memcpy(srv_data_file_names[i], str_buf,
ut_strlen(str_buf) + 1);
srv_data_file_sizes[i] = ulint_val
* ((1024 * 1024) / UNIV_PAGE_SIZE);
}
err = srv_read_init_val(initfile,
"NUMBER_OF_MIRRORED_LOG_GROUPS", NULL,
&srv_n_log_groups, FALSE);
if (err != DB_SUCCESS) return(err);
err = srv_read_init_val(initfile,
"NUMBER_OF_LOG_FILES_IN_GROUP", NULL,
&srv_n_log_files, FALSE);
if (err != DB_SUCCESS) return(err);
err = srv_read_init_val(initfile, "LOG_FILE_SIZE_KB", NULL,
&srv_log_file_size, FALSE);
if (err != DB_SUCCESS) return(err);
srv_log_file_size = srv_log_file_size / (UNIV_PAGE_SIZE / 1024);
srv_log_group_home_dirs = ut_malloc(srv_n_log_files * sizeof(char*));
for (i = 0; i < srv_n_log_groups; i++) {
err = srv_read_init_val(initfile,
"INNOBASE_LOG_GROUP_HOME_DIR",
str_buf, NULL, FALSE);
if (err != DB_SUCCESS) return(err);
srv_log_group_home_dirs[i] = ut_malloc(ut_strlen(str_buf) + 1);
ut_memcpy(srv_log_group_home_dirs[i], str_buf,
ut_strlen(str_buf) + 1);
}
err = srv_read_init_val(initfile, "INNOBASE_LOG_ARCH_DIR",
str_buf, NULL, FALSE);
if (err != DB_SUCCESS) return(err);
srv_arch_dir = ut_malloc(ut_strlen(str_buf) + 1);
ut_memcpy(srv_arch_dir, str_buf, ut_strlen(str_buf) + 1);
err = srv_read_init_val(initfile, "LOG_ARCHIVE_ON(1/0)", NULL,
&srv_log_archive_on, FALSE);
if (err != DB_SUCCESS) return(err);
err = srv_read_init_val(initfile, "LOG_BUFFER_SIZE_KB", NULL,
&srv_log_buffer_size, FALSE);
if (err != DB_SUCCESS) return(err);
srv_log_buffer_size = srv_log_buffer_size / (UNIV_PAGE_SIZE / 1024);
err = srv_read_init_val(initfile, "FLUSH_LOG_AT_TRX_COMMIT(1/0)", NULL,
&srv_flush_log_at_trx_commit, FALSE);
if (err != DB_SUCCESS) return(err);
err = srv_read_init_val(initfile, "BUFFER_POOL_SIZE_MB", NULL,
&srv_pool_size, FALSE);
if (err != DB_SUCCESS) return(err);
srv_pool_size = srv_pool_size * ((1024 * 1024) / UNIV_PAGE_SIZE);
err = srv_read_init_val(initfile, "ADDITIONAL_MEM_POOL_SIZE_MB", NULL,
&srv_mem_pool_size, FALSE);
if (err != DB_SUCCESS) return(err);
srv_mem_pool_size = srv_mem_pool_size * 1024 * 1024;
srv_lock_table_size = 20 * srv_pool_size;
err = srv_read_init_val(initfile, "NUMBER_OF_FILE_IO_THREADS", NULL,
&srv_n_file_io_threads, FALSE);
if (err != DB_SUCCESS) return(err);
err = srv_read_init_val(initfile, "SRV_RECOVER_FROM_BACKUP",
NULL, NULL, TRUE);
if (err == DB_SUCCESS) {
srv_archive_recovery = TRUE;
srv_archive_recovery_limit_lsn = ut_dulint_max;
err = srv_read_init_val(initfile, NULL, NULL, &val1, TRUE);
err = srv_read_init_val(initfile, NULL, NULL, &val2, TRUE);
if (err == DB_SUCCESS) {
srv_archive_recovery_limit_lsn =
ut_dulint_create(val1, val2);
}
}
/* err = srv_read_init_val(initfile,
"SYNC_NUMBER_OF_SPIN_WAIT_ROUNDS", NULL,
&srv_n_spin_wait_rounds);
err = srv_read_init_val(initfile, "SYNC_SPIN_WAIT_DELAY", NULL,
&srv_spin_wait_delay); */
return(DB_SUCCESS);
}
/*************************************************************************
Reads keywords and a values from an initfile. In case of an error, exits
from the process. */
void
srv_read_initfile(
/*==============*/
FILE* initfile) /* in: file pointer */
{
char str_buf[10000];
ulint ulint_val;
srv_read_init_val(initfile, FALSE, "SRV_ENDPOINT_NAME", str_buf,
&ulint_val);
ut_a(ut_strlen(str_buf) < COM_MAX_ADDR_LEN);
ut_memcpy(srv_endpoint_name, str_buf, COM_MAX_ADDR_LEN);
srv_read_init_val(initfile, TRUE, "SRV_N_COM_THREADS", str_buf,
&srv_n_com_threads);
srv_read_init_val(initfile, TRUE, "SRV_N_WORKER_THREADS", str_buf,
&srv_n_worker_threads);
srv_read_init_val(initfile, TRUE, "SYNC_N_SPIN_WAIT_ROUNDS", str_buf,
&srv_n_spin_wait_rounds);
srv_read_init_val(initfile, TRUE, "SYNC_SPIN_WAIT_DELAY", str_buf,
&srv_spin_wait_delay);
srv_read_init_val(initfile, TRUE, "THREAD_PRIORITY_BOOST", str_buf,
&srv_priority_boost);
srv_read_init_val(initfile, TRUE, "N_SPACES", str_buf, &srv_n_spaces);
srv_read_init_val(initfile, TRUE, "N_FILES", str_buf, &srv_n_files);
srv_read_init_val(initfile, TRUE, "FILE_SIZE", str_buf,
&srv_file_size);
srv_read_init_val(initfile, TRUE, "N_LOG_GROUPS", str_buf,
&srv_n_log_groups);
srv_read_init_val(initfile, TRUE, "N_LOG_FILES", str_buf,
&srv_n_log_files);
srv_read_init_val(initfile, TRUE, "LOG_FILE_SIZE", str_buf,
&srv_log_file_size);
srv_read_init_val(initfile, TRUE, "LOG_ARCHIVE_ON", str_buf,
&srv_log_archive_on);
srv_read_init_val(initfile, TRUE, "LOG_BUFFER_SIZE", str_buf,
&srv_log_buffer_size);
srv_read_init_val(initfile, TRUE, "FLUSH_LOG_AT_TRX_COMMIT", str_buf,
&srv_flush_log_at_trx_commit);
srv_read_init_val(initfile, TRUE, "POOL_SIZE", str_buf,
&srv_pool_size);
srv_read_init_val(initfile, TRUE, "MEM_POOL_SIZE", str_buf,
&srv_mem_pool_size);
srv_read_init_val(initfile, TRUE, "LOCK_TABLE_SIZE", str_buf,
&srv_lock_table_size);
srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_PCT", str_buf,
&srv_sim_disk_wait_pct);
srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_LEN", str_buf,
&srv_sim_disk_wait_len);
srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_BY_YIELD", str_buf,
&srv_sim_disk_wait_by_yield);
srv_read_init_val(initfile, TRUE, "SIM_DISK_WAIT_BY_WAIT", str_buf,
&srv_sim_disk_wait_by_wait);
srv_read_init_val(initfile, TRUE, "MEASURE_CONTENTION", str_buf,
&srv_measure_contention);
srv_read_init_val(initfile, TRUE, "MEASURE_BY_SPIN", str_buf,
&srv_measure_by_spin);
srv_read_init_val(initfile, TRUE, "PRINT_THREAD_RELEASES", str_buf,
&srv_print_thread_releases);
srv_read_init_val(initfile, TRUE, "PRINT_LOCK_WAITS", str_buf,
&srv_print_lock_waits);
if (srv_print_lock_waits) {
lock_print_waits = TRUE;
}
srv_read_init_val(initfile, TRUE, "PRINT_BUF_IO", str_buf,
&srv_print_buf_io);
if (srv_print_buf_io) {
buf_debug_prints = TRUE;
}
srv_read_init_val(initfile, TRUE, "PRINT_LOG_IO", str_buf,
&srv_print_log_io);
if (srv_print_log_io) {
log_debug_writes = TRUE;
}
srv_read_init_val(initfile, TRUE, "PRINT_PARSED_SQL", str_buf,
&srv_print_parsed_sql);
if (srv_print_parsed_sql) {
pars_print_lexed = TRUE;
}
srv_read_init_val(initfile, TRUE, "PRINT_LATCH_WAITS", str_buf,
&srv_print_latch_waits);
srv_read_init_val(initfile, TRUE, "TEST_EXTRA_MUTEXES", str_buf,
&srv_test_extra_mutexes);
srv_read_init_val(initfile, TRUE, "TEST_NOCACHE", str_buf,
&srv_test_nocache);
srv_read_init_val(initfile, TRUE, "TEST_CACHE_EVICT", str_buf,
&srv_test_cache_evict);
srv_read_init_val(initfile, TRUE, "TEST_SYNC", str_buf,
&srv_test_sync);
srv_read_init_val(initfile, TRUE, "TEST_N_THREADS", str_buf,
&srv_test_n_threads);
srv_read_init_val(initfile, TRUE, "TEST_N_LOOPS", str_buf,
&srv_test_n_loops);
srv_read_init_val(initfile, TRUE, "TEST_N_FREE_RNDS", str_buf,
&srv_test_n_free_rnds);
srv_read_init_val(initfile, TRUE, "TEST_N_RESERVED_RNDS", str_buf,
&srv_test_n_reserved_rnds);
srv_read_init_val(initfile, TRUE, "TEST_N_MUTEXES", str_buf,
&srv_test_n_mutexes);
srv_read_init_val(initfile, TRUE, "TEST_ARRAY_SIZE", str_buf,
&srv_test_array_size);
}
#endif
/************************************************************************* /*************************************************************************
Initializes the server. */ Initializes the server. */

View File

@ -441,9 +441,9 @@ io_handler_thread(
} }
#ifdef __WIN__ #ifdef __WIN__
#define SRV_PATH_SEPARATOR "\\" #define SRV_PATH_SEPARATOR '\\'
#else #else
#define SRV_PATH_SEPARATOR "/" #define SRV_PATH_SEPARATOR '/'
#endif #endif
/************************************************************************* /*************************************************************************
@ -470,31 +470,26 @@ srv_normalize_path_for_win(
Adds a slash or a backslash to the end of a string if it is missing Adds a slash or a backslash to the end of a string if it is missing
and the string is not empty. */ and the string is not empty. */
static
char* char*
srv_add_path_separator_if_needed( srv_add_path_separator_if_needed(
/*=============================*/ /*=============================*/
/* out, own: string which has the separator if the /* out: string which has the separator if the
string is not empty */ string is not empty */
char* str) /* in: null-terminated character string */ char* str) /* in: null-terminated character string */
{ {
char* out_str; char* out_str;
ulint len = ut_strlen(str);
if (ut_strlen(str) == 0) { if (len == 0 || str[len - 1] == SRV_PATH_SEPARATOR) {
return(str); return(str);
} }
if (str[ut_strlen(str) - 1] == SRV_PATH_SEPARATOR[0]) { out_str = ut_malloc(len + 2);
out_str = ut_malloc(ut_strlen(str) + 1); memcpy(out_str, str, len);
out_str[len] = SRV_PATH_SEPARATOR;
sprintf(out_str, "%s", str); out_str[len + 1] = 0;
return(out_str);
}
out_str = ut_malloc(ut_strlen(str) + 2);
sprintf(out_str, "%s%s", str, SRV_PATH_SEPARATOR);
return(out_str); return(out_str);
} }

View File

@ -1,15 +0,0 @@
include ..\..\makefile.i
tssrv: ..\srv.lib tssrv.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\srv.lib ..\..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\btr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tssrv.c $(LFL)

View File

@ -1,118 +0,0 @@
/************************************************************************
Database client test program
(c) 1995 Innobase Oy
Created 10/10/1995 Heikki Tuuri
*************************************************************************/
#include "com0com.h"
#include "com0shm.h"
#include "ut0ut.h"
#include "mem0mem.h"
#include "os0thread.h"
#include "sync0ipm.h"
#include "sync0sync.h"
byte buf[10000];
char addr[150];
void
test1(void)
/*=======*/
{
com_endpoint_t* ep;
ulint ret;
ulint size;
ulint len;
ulint addr_len;
ulint i, j;
ulint tm, oldtm;
oldtm = ut_clock();
for (i = 0; i < 10000; i++) {
ut_delay(100);
}
for (j = 0; j < i / 10; j++) {
ut_delay(200);
}
tm = ut_clock();
printf("Wall clock time for test without server %ld milliseconds\n",
tm - oldtm);
printf("%lu rounds\n", i);
ep = com_endpoint_create(COM_SHM);
ut_a(ep);
size = 8192;
ret = com_endpoint_set_option(ep, COM_OPT_MAX_DGRAM_SIZE,
(byte*)&size, 0);
ut_a(ret == 0);
ret = com_bind(ep, "CLI", 3);
ut_a(ret == 0);
printf("Client endpoint created!\n");
oldtm = ut_clock();
for (i = 0; i < 50000; i++) {
ret = com_sendto(ep, (byte*)"Hello from client!\n", 18, "ibsrv", 5);
ut_a(ret == 0);
ret = com_recvfrom(ep, buf, 10000, &len, addr, 150, &addr_len);
ut_a(ret == 0);
buf[len] = '\0';
addr[addr_len] = '\0';
/*
printf(
"Message of len %lu\n%s \nreceived from address %s of len %lu\n",
len, buf, addr, addr_len);
*/
}
tm = ut_clock();
printf("Wall clock time for test %ld milliseconds\n", tm - oldtm);
printf("%lu message pairs\n", i);
printf("System calls in com_shm %lu ip_mutex %lu mutex %lu\n",
com_shm_system_call_count,
ip_mutex_system_call_count,
mutex_system_call_count);
ret = com_endpoint_free(ep);
ut_ad(ret == 0);
}
void
main(void)
/*======*/
{
sync_init();
mem_init();
test1();
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1,39 +0,0 @@
/******************************************************
Test for the database server
(c) 1995 Innobase Oy
Created 10/10/1995 Heikki Tuuri
*******************************************************/
#include "srv0srv.h"
#include "os0proc.h"
#include "ut0mem.h"
/***************************************************************************
The main function of the server. */
void
main(
/*=*/
#ifdef notdefined
ulint argc, /* in: number of string arguments given on
the command line */
char* argv[]
#endif
) /* in: array of character pointers giving
the arguments */
{
/*
if (argc != 2) {
printf("Error! Wrong number of command line arguments!\n");
printf("Usage: ib <init-file-name>\n");
os_process_exit(1);
}
*/
srv_boot("init.ib"/*argv[1]*/);
os_process_exit(0);
}

View File

@ -318,10 +318,10 @@ rw_lock_x_lock_low(
lock->writer_count++; lock->writer_count++;
lock->pass = pass; lock->pass = pass;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
file_name, line); file_name, line);
#endif #endif
lock->last_x_file_name = file_name; lock->last_x_file_name = file_name;
lock->last_x_line = line; lock->last_x_line = line;
@ -334,10 +334,10 @@ rw_lock_x_lock_low(
lock->pass = pass; lock->pass = pass;
lock->writer_is_wait_ex = TRUE; lock->writer_is_wait_ex = TRUE;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX, rw_lock_add_debug_info(lock, pass, RW_LOCK_WAIT_EX,
file_name, line); file_name, line);
#endif #endif
return(RW_LOCK_WAIT_EX); return(RW_LOCK_WAIT_EX);
} }
@ -353,11 +353,11 @@ rw_lock_x_lock_low(
lock->pass = pass; lock->pass = pass;
lock->writer_is_wait_ex = FALSE; lock->writer_is_wait_ex = FALSE;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX); rw_lock_remove_debug_info(lock, pass, RW_LOCK_WAIT_EX);
rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, rw_lock_add_debug_info(lock, pass, RW_LOCK_EX,
file_name, line); file_name, line);
#endif #endif
lock->last_x_file_name = file_name; lock->last_x_file_name = file_name;
lock->last_x_line = line; lock->last_x_line = line;
@ -376,10 +376,10 @@ rw_lock_x_lock_low(
lock->writer_count++; lock->writer_count++;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name, rw_lock_add_debug_info(lock, pass, RW_LOCK_EX, file_name,
line); line);
#endif #endif
lock->last_x_file_name = file_name; lock->last_x_file_name = file_name;
lock->last_x_line = line; lock->last_x_line = line;

View File

@ -301,9 +301,9 @@ mutex_enter_nowait(
if (!mutex_test_and_set(mutex)) { if (!mutex_test_and_set(mutex)) {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line); mutex_set_debug_info(mutex, file_name, line);
#endif #endif
mutex->file_name = file_name; mutex->file_name = file_name;
mutex->line = line; mutex->line = line;
@ -402,9 +402,9 @@ spin_loop:
if (mutex_test_and_set(mutex) == 0) { if (mutex_test_and_set(mutex) == 0) {
/* Succeeded! */ /* Succeeded! */
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line); mutex_set_debug_info(mutex, file_name, line);
#endif #endif
mutex->file_name = file_name; mutex->file_name = file_name;
mutex->line = line; mutex->line = line;
@ -449,9 +449,9 @@ spin_loop:
sync_array_free_cell(sync_primary_wait_array, index); sync_array_free_cell(sync_primary_wait_array, index);
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
mutex_set_debug_info(mutex, file_name, line); mutex_set_debug_info(mutex, file_name, line);
#endif #endif
mutex->file_name = file_name; mutex->file_name = file_name;
mutex->line = line; mutex->line = line;
@ -671,18 +671,18 @@ ibool
sync_all_freed(void) sync_all_freed(void)
/*================*/ /*================*/
{ {
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
if (mutex_n_reserved() + rw_lock_n_locked() == 0) { if (mutex_n_reserved() + rw_lock_n_locked() == 0) {
return(TRUE); return(TRUE);
} else { } else {
return(FALSE); return(FALSE);
} }
#else #else
ut_error; ut_error;
return(FALSE); return(FALSE);
#endif #endif
} }
/********************************************************************** /**********************************************************************

View File

@ -1,14 +0,0 @@
include ..\..\makefile.i
tssync: ..\sync.lib tssync.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\sync.lib ..\..\mach.lib ..\..\ut.lib ..\..\mem.lib ..\..\os.lib tssync.c $(LFL)

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +0,0 @@
include ..\..\makefile.i
tsthr: ..\thr.lib tsthr.c makefile
$(CCOM) $(CFL) -I.. -I..\.. ..\thr.lib ..\..\ha.lib ..\..\sync.lib ..\..\ut.lib ..\..\mem.lib ..\..\os.lib tsthr.c $(LFL)

View File

@ -1,131 +0,0 @@
/************************************************************************
The test module for the thread management of Innobase
(c) 1995 Innobase Oy
Created 10/5/1995 Heikki Tuuri
*************************************************************************/
#include "../thr0loc.h"
#include "sync0sync.h"
#include "mem0mem.h"
#include "os0thread.h"
#include "os0sync.h"
#include "ut0ut.h"
ulint val = 500;
os_event_t event;
/******************************************************************
Thread start function in test1. */
ulint
thread1(
/*====*/
void* arg)
{
ulint n;
thr_local_create();
n = *((ulint*)arg);
printf("Thread %lu starts\n", n);
thr_local_set_slot_no(os_thread_get_curr_id(), n);
ut_a(n == thr_local_get_slot_no(os_thread_get_curr_id()));
os_event_wait(event);
thr_local_free();
os_thread_exit(0);
return(0);
}
/******************************************************************
Test function for local storage. */
void
test1(void)
/*=======*/
{
os_thread_t thr1, thr2, thr3, thr4, thr5;
os_thread_id_t id1, id2, id3, id4, id5;
ulint tm, oldtm;
ulint n1, n2, n3, n4, n5;
printf("-------------------------------------------\n");
printf("THR-TEST 1. Test of local storage\n");
event = os_event_create(NULL);
oldtm = ut_clock();
n1 = 1;
thr1 = os_thread_create(thread1,
&n1,
&id1);
n2 = 2;
thr2 = os_thread_create(thread1,
&n2,
&id2);
n3 = 3;
thr3 = os_thread_create(thread1,
&n3,
&id3);
n4 = 4;
thr4 = os_thread_create(thread1,
&n4,
&id4);
n5 = 5;
thr5 = os_thread_create(thread1,
&n5,
&id5);
os_thread_sleep(500000);
ut_a(n1 == thr_local_get_slot_no(id1));
ut_a(n2 == thr_local_get_slot_no(id2));
ut_a(n3 == thr_local_get_slot_no(id3));
ut_a(n4 == thr_local_get_slot_no(id4));
ut_a(n5 == thr_local_get_slot_no(id5));
os_event_set(event);
os_thread_wait(thr1);
os_thread_wait(thr2);
os_thread_wait(thr3);
os_thread_wait(thr4);
os_thread_wait(thr5);
tm = ut_clock();
printf("Wall clock time for 5 threads %ld milliseconds\n",
tm - oldtm);
}
/************************************************************************
Main test function. */
void
main(void)
/*======*/
{
ulint tm, oldtm;
sync_init();
mem_init();
thr_local_init();
oldtm = ut_clock();
test1();
thr_local_close();
tm = ut_clock();
printf("Wall clock time for test %lu milliseconds\n", tm - oldtm);
printf("TESTS COMPLETED SUCCESSFULLY!\n");
}

View File

@ -1147,8 +1147,6 @@ trx_sig_send(
ut_a(0); ut_a(0);
/* sess_raise_error_low(trx, 0, 0, NULL, NULL, NULL, NULL,
"Incompatible signal"); */
return(FALSE); return(FALSE);
} }
@ -1197,9 +1195,6 @@ trx_sig_send(
in the error state: */ in the error state: */
ut_a(0); ut_a(0);
sess_raise_error_low(trx, 0, 0, NULL, NULL, NULL, NULL,
(char *) "Signal from another session, or a break execution signal");
} }
/* If there were no other signals ahead in the queue, try to start /* If there were no other signals ahead in the queue, try to start

View File

@ -1,16 +0,0 @@
include ..\..\makefile.i
tstrx: ..\trx.lib tstrx.c
$(CCOM) $(CFL) -I.. -I..\.. ..\trx.lib ..\..\pars.lib ..\..\que.lib ..\..\lock.lib ..\..\row.lib ..\..\read.lib ..\..\srv.lib ..\..\com.lib ..\..\usr.lib ..\..\thr.lib ..\..\btr.lib ..\..\fut.lib ..\..\fsp.lib ..\..\page.lib ..\..\dyn.lib ..\..\mtr.lib ..\..\log.lib ..\..\rem.lib ..\..\fil.lib ..\..\buf.lib ..\..\dict.lib ..\..\data.lib ..\..\mach.lib ..\..\ha.lib ..\..\ut.lib ..\..\sync.lib ..\..\mem.lib ..\..\os.lib tstrx.c $(LFL)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -28,6 +28,13 @@ Created 6/25/1996 Heikki Tuuri
/* The session system global data structure */ /* The session system global data structure */
sess_sys_t* sess_sys = NULL; sess_sys_t* sess_sys = NULL;
/*************************************************************************
Closes a session, freeing the memory occupied by it. */
static
void
sess_close(
/*=======*/
sess_t* sess); /* in, own: session object */
/************************************************************************* /*************************************************************************
Communicates an error message to the client. If sess->client_waits is not Communicates an error message to the client. If sess->client_waits is not
TRUE, puts the session to error state and does not try to send the error TRUE, puts the session to error state and does not try to send the error
@ -85,42 +92,6 @@ sess_cli_msg_set_sess(
mach_write_to_4(str + SESS_CLI_MSG_SESS_ID_CHECK, fold); mach_write_to_4(str + SESS_CLI_MSG_SESS_ID_CHECK, fold);
} }
/*************************************************************************
Returns the session to which a message from a client is addressed.
NOTE: this function does not assume that the message is uncorrupted. */
static
sess_t*
sess_cli_msg_get_sess(
/*==================*/
/* out: session, NULL if not found */
byte* str, /* in: message string */
ulint len) /* in: message string length */
{
sess_t* sess;
ulint fold;
dulint id;
ut_ad(mutex_own(&kernel_mutex));
if (len < SESS_CLI_MSG_SESS_ID_CHECK + 4) {
return(NULL);
}
id = mach_read_from_8(str + SESS_CLI_MSG_SESS_ID);
fold = sess_id_fold(id);
if (fold != mach_read_from_4(str + SESS_CLI_MSG_SESS_ID_CHECK)) {
return(NULL);
}
HASH_SEARCH(hash, sess_sys->hash, fold, sess,
UT_DULINT_EQ(id, sess->id));
return(sess);
}
/*************************************************************************** /***************************************************************************
Decrements the reference count of a session and closes it, if desired. */ Decrements the reference count of a session and closes it, if desired. */
UNIV_INLINE UNIV_INLINE
@ -311,6 +282,7 @@ sess_open(
/************************************************************************* /*************************************************************************
Closes a session, freeing the memory occupied by it. */ Closes a session, freeing the memory occupied by it. */
static
void void
sess_close( sess_close(
/*=======*/ /*=======*/
@ -595,330 +567,6 @@ sess_error_low(
NULL, NULL, NULL); NULL, NULL, NULL);
} }
/*************************************************************************
Raises an SQL error. */
void
sess_raise_error_low(
/*=================*/
trx_t* trx, /* in: transaction */
ulint err_no, /* in: error number */
ulint type, /* in: more info of the error, or 0 */
dict_table_t* table, /* in: dictionary table or NULL */
dict_index_t* index, /* in: table index or NULL */
dtuple_t* tuple, /* in: tuple to insert or NULL */
rec_t* rec, /* in: record or NULL */
char* err_str)/* in: arbitrary null-terminated error string,
or NULL */
{
char* str;
ulint len;
ut_ad(mutex_own(&kernel_mutex));
str = mem_alloc(64000);
len = 0;
len += sprintf(str + len, "Error number: %lu", err_no);
if (type) {
len += sprintf(str + len, ", type: %lu", type);
}
if (table) {
len += sprintf(str + len, ", table: %s", table->name);
}
if (index) {
len += sprintf(str + len, ", index: %s", index->name);
}
if (tuple) {
len += sprintf(str + len, ", tuple:");
len += dtuple_sprintf(str + len, 8192, tuple);
}
if (rec) {
len += sprintf(str + len, ", record:");
len += rec_sprintf(str + len, 8192, rec);
}
if (err_str) {
len += sprintf(str + len, ", %s", err_str);
}
str[len] = '\0';
ut_a(len < 64000);
if (trx->sess) {
sess_error_low(trx->sess, err_no, str);
} else {
mem_free(str);
}
}
/***************************************************************************
Processes a client message which is part of a bigger message. */
static
ibool
sess_receive_msg_part(
/*==================*/
/* TRUE if message completed */
sess_t* sess, /* in: session */
byte* str, /* in: message string */
ulint len) /* in: message length */
{
ulint cont;
cont = sess_cli_msg_get_continue(str);
ut_ad(cont != SESS_MSG_SINGLE_PART);
if (cont == SESS_MSG_FIRST_PART) {
if (sess->big_msg) {
sess_error_low(sess, SESS_ERR_MSG_LOST, NULL);
return(FALSE);
}
sess->big_msg_size = 1024 * sess_cli_msg_get_cont_size(str);
sess->big_msg = mem_alloc(sess->big_msg_size);
if (sess->big_msg == NULL) {
sess_error_low(sess, SESS_ERR_OUT_OF_MEMORY, NULL);
return(FALSE);
}
ut_memcpy(sess->big_msg, str, len);
sess->big_msg_len = len;
return(FALSE);
} else {
if (sess->big_msg == NULL) {
sess_error_low(sess, SESS_ERR_MSG_LOST, NULL);
return(FALSE);
}
ut_memcpy(sess->big_msg + sess->big_msg_len,
str + SESS_CLI_MSG_DATA, len - SESS_CLI_MSG_DATA);
sess->big_msg_len += len - SESS_CLI_MSG_DATA;
if (cont == SESS_MSG_MIDDLE_PART) {
return(FALSE);
}
return(TRUE);
}
}
/***************************************************************************
Processes a client message which requires SQL parsing. This function decodes
the client message built in SQLPrepare. NOTE: The kernel mutex is temporarily
released within this function. */
static
void
sess_receive_prepare(
/*=================*/
sess_t* sess, /* in: session */
byte* cli_msg,/* in: client message */
ulint len) /* in: message length */
{
dulint error_count;
que_t* graph;
byte msg[ODBC_DATAGRAM_SIZE];
UT_NOT_USED(len);
ut_ad(mutex_own(&kernel_mutex));
error_count = sess->error_count;
/* Make sure the session object is not freed during the parsing */
sess_refer_count_inc(sess);
/* We release the kernel mutex before parsing the command: this is
to reduce contention on the kernel mutex */
mutex_exit(&kernel_mutex);
/* printf("To parse query %s\n", (char*)(cli_msg + SESS_CLI_MSG_DATA)); */
graph = pars_sql((char*)(cli_msg + SESS_CLI_MSG_DATA));
mutex_enter(&kernel_mutex);
if (graph == NULL) {
/* Error in parsing */
sess_error_low(sess, SESS_ERR_SQL_ERROR, NULL);
sess_refer_count_dec(sess);
ut_error;
return;
}
if (!UT_DULINT_EQ(error_count, sess->error_count)) {
/* An error, or an asyncronous signal on the session happened
when the kernel mutex was not reserved: discard graph */
graph->state = QUE_FORK_INVALID;
que_graph_try_free(graph);
sess_refer_count_dec(sess);
ut_error;
return;
}
UT_LIST_ADD_LAST(graphs, sess->graphs, graph);
graph->id = sess->next_graph_id;
sess->next_graph_id++;
/* Tell the client that the preparation succeeded and communicate info
about the possible query parameters: the message will be decoded in
SQLPrepare */
ut_ad(sess->client_waits);
sess_srv_msg_init(sess, msg, SESS_SRV_SUCCESS);
mach_write_to_4(msg + SESS_SRV_MSG_DATA, graph->id);
mutex_exit(&kernel_mutex);
len = pars_write_query_param_info(msg + SESS_SRV_MSG_DATA + 4, graph);
mutex_enter(&kernel_mutex);
sess_srv_msg_send(sess, msg, SESS_SRV_MSG_DATA + 4 + len,
SESS_RELEASE_KERNEL);
sess_refer_count_dec(sess);
}
/***************************************************************************
Processes a client message which does not require SQL parsing. This function
decodes the client message built in SQLExecute. */
static
void
sess_receive_command(
/*=================*/
sess_t* sess, /* in: session */
byte* cli_msg,/* in: client message */
ulint len, /* in: message length */
ulint type) /* in: message type */
{
proc_node_t* proc_node;
call_node_t* call_node;
dict_proc_t* dict_proc;
que_thr_t* thr;
que_t* graph;
ulint stat_id;
UT_NOT_USED(len);
UT_NOT_USED(type);
ut_ad(mutex_own(&kernel_mutex));
sess->client_waits = TRUE;
stat_id = mach_read_from_4(cli_msg + SESS_CLI_MSG_DATA);
/* Look for the statement from the list of query graphs */
graph = UT_LIST_GET_FIRST(sess->graphs);
while (graph != NULL) {
if (graph->id == stat_id) {
break;
}
graph = UT_LIST_GET_NEXT(graphs, graph);
}
if (graph == NULL) {
/* Could not find the right graph: error */
sess_error_low(sess, SESS_ERR_STMT_NOT_FOUND, NULL);
return;
}
if (graph->state != QUE_FORK_COMMAND_WAIT) {
sess_error_low(sess, SESS_ERR_STMT_NOT_READY, NULL);
return;
}
/* printf("To execute stat %lu\n", stat_id); */
if (graph->fork_type == QUE_FORK_PROCEDURE_CALL) {
/* It is a stored procedure call: retrieve a parsed copy of
the procedure from the dictionary cache */
mutex_exit(&kernel_mutex);
call_node = que_fork_get_child(graph);
graph = dict_procedure_reserve_parsed_copy(
call_node->procedure_def);
graph->trx = sess->trx;
/* Retrieve the procedure input parameters from the message */
pars_proc_read_input_params_from_buf(graph,
cli_msg + SESS_CLI_MSG_DATA + 4);
mutex_enter(&kernel_mutex);
} else {
/* It is a create procedure command: add the procedure to the
dictionary cache */
ut_ad(graph->fork_type == QUE_FORK_PROCEDURE);
mutex_exit(&kernel_mutex);
proc_node = que_fork_get_child(graph);
dict_proc = dict_mem_procedure_create(proc_node->proc_id->name,
proc_node->sym_tab->sql_string,
graph);
dict_procedure_add_to_cache(dict_proc);
mutex_enter(&kernel_mutex);
sess_srv_msg_send_simple(sess, SESS_SRV_SUCCESS,
SESS_RELEASE_KERNEL);
return;
}
/* Choose a query thread for execution */
thr = que_fork_start_command(graph, SESS_COMM_EXECUTE, 0);
ut_ad(thr);
sess->trx->graph = graph;
mutex_exit(&kernel_mutex);
/* Run query threads with the kernel mutex released */
que_run_threads(thr);
mutex_enter(&kernel_mutex);
}
/*************************************************************************** /***************************************************************************
When a command has been completed, this function sends the message about it When a command has been completed, this function sends the message about it
to the client. */ to the client. */
@ -936,239 +584,3 @@ sess_command_completed_message(
SESS_RELEASE_KERNEL); SESS_RELEASE_KERNEL);
mutex_exit(&kernel_mutex); mutex_exit(&kernel_mutex);
} }
/***************************************************************************
Processes a break message from the client. */
static
void
sess_receive_break(
/*===============*/
sess_t* sess) /* in: session */
{
ut_ad(mutex_own(&kernel_mutex));
/* Rollback the latest incomplete SQL statement */
sess_error_low(sess, SESS_ERR_BREAK_BY_CLIENT, NULL);
}
/***************************************************************************
Processes a message from a client. NOTE: Releases the kernel mutex temporarily
when parsing an SQL string. */
void
sess_receive_msg_rel_kernel(
/*========================*/
sess_t* sess, /* in: session */
byte* str, /* in: message string */
ulint len) /* in: message length */
{
dulint msg_no;
ulint msg_type;
ulint cont;
ibool is_big_msg = FALSE;
ibool client_waited;
ut_ad(mutex_own(&kernel_mutex));
ut_ad(!sess->disconnecting);
client_waited = sess->client_waits;
sess->client_waits = TRUE;
if (sess->state == SESS_ERROR) {
/* Send a buffered error message */
sess_srv_msg_send_error(sess);
return;
}
if (FALSE == sess_cli_msg_check_consistency(str, len)) {
/* Message from the client was corrupted */
sess_error_low(sess, SESS_ERR_MSG_CORRUPTED, NULL);
return;
}
msg_no = sess_cli_msg_get_msg_no(str);
UT_DULINT_INC(sess->msgs_recv);
if (!UT_DULINT_EQ(msg_no, sess->msgs_recv)) {
sess_error_low(sess, SESS_ERR_MSG_LOST, NULL);
sess->msgs_recv = msg_no;
return;
}
msg_type = sess_cli_msg_get_type(str);
if (msg_type == SESS_CLI_BREAK_EXECUTION) {
sess_receive_break(sess);
return;
}
if (client_waited) {
/* Client sent an extraneous message which is not a break
command: an error */
sess_error_low(sess, SESS_ERR_EXTRANEOUS_MSG, NULL);
return;
}
/*-----------------------------------------------------------*/
/* Handle big messages */
cont = sess_cli_msg_get_continue(str);
if (cont == SESS_MSG_SINGLE_PART) {
if (sess->big_msg) {
sess_error_low(sess, SESS_ERR_MSG_LOST, NULL);
return;
}
} else {
ut_error; /* Not in use */
is_big_msg = sess_receive_msg_part(sess, str, len);
if (is_big_msg) {
str = sess->big_msg;
len = sess->big_msg_len;
sess->big_msg = NULL;
} else {
return;
}
}
/*-----------------------------------------------------------*/
/* The session has received a complete message from the client */
ut_ad(!UT_LIST_GET_FIRST((sess->trx)->signals));
if (msg_type == SESS_CLI_PREPARE) {
/* Note that the kernel mutex is temporarily released when
the SQL string is parsed */
sess_receive_prepare(sess, str, len);
} else {
/* Note that the kernel mutex is temporarily released when the
command is executed */
sess_receive_command(sess, str, len, msg_type);
}
if (is_big_msg) {
mem_free(str);
}
}
/***********************************************************************
Opens a new connection and creates a session. */
static
ibool
sess_open_connection(
/*=================*/
byte* str, /* in: message string */
ulint len, /* in: string length */
byte* addr, /* in: user address string */
ulint alen) /* in: user address length */
{
dulint sess_id;
sess_t* sess;
sess_id = mach_read_from_8(str + SESS_CLI_MSG_SESS_ID);
if (!(UT_DULINT_EQ(sess_id, ut_dulint_zero))
|| !(sess_cli_msg_get_type(str) == SESS_CLI_CONNECT)) {
/* It is not a valid connect message */
return(FALSE);
}
ut_a(len == SESS_CLI_MSG_DATA);
sess = sess_open(srv_sys->endpoint, addr, alen);
sess_srv_msg_send_simple(sess, SESS_SRV_ACCEPT_CONNECT,
SESS_NOT_RELEASE_KERNEL);
return(TRUE);
}
/***********************************************************************
Starts a new connection and a session, or starts a query based on a client
message. This is called by a SRV_COM thread. */
void
sess_process_cli_msg(
/*=================*/
byte* str, /* in: message string */
ulint len, /* in: string length */
byte* addr, /* in: address string */
ulint alen) /* in: address length */
{
sess_t* sess;
ibool success;
UT_NOT_USED(addr);
UT_NOT_USED(alen);
mutex_enter(&kernel_mutex);
sess = sess_cli_msg_get_sess(str, len);
if (sess == NULL) {
/* There was no matching session */
if (sess_cli_msg_check_consistency(str, len)) {
/* As the message is consistent, it may be a connect
message */
/* printf("%s\n", addr); */
success = sess_open_connection(str, len, addr, alen);
if (success) {
mutex_exit(&kernel_mutex);
return;
}
}
/* Could not make sense of the message: write an error entry
to the system error log */
/* srv_err_log_insert(
"MESSAGE SENT TO AN UNKNOWN SESSION");*/
ut_error;
mutex_exit(&kernel_mutex);
return;
}
if (sess->disconnecting) {
/* srv_err_log_insert(
"MESSAGE SENT TO A DISCONNECTING SESSION");*/
ut_error;
mutex_exit(&kernel_mutex);
return;
}
sess_receive_msg_rel_kernel(sess, str, len);
mutex_exit(&kernel_mutex);
}

View File

@ -1,12 +0,0 @@
include ..\..\makefile.i
tsut: ..\ut.lib tsut.c
$(CCOM) $(CFL) -I.. -I..\.. ..\ut.lib ..\..\os.lib tsut.c $(LFL)

View File

@ -1,347 +0,0 @@
/************************************************************************
The test module for the utilities
(c) 1995 Innobase Oy
Created 10/28/1995 Heikki Tuuri
*************************************************************************/
#include "../ut0lst.h"
#include "../ut0mem.h"
#include "../ut0byte.h"
#include "../ut0sort.h"
#include "../ut0rnd.h"
typedef struct node_struct node_t;
struct node_struct {
ulint index;
ulint zyx;
UT_LIST_NODE_T(node_t) list1;
ulint yzx;
UT_LIST_NODE_T(node_t) list2;
};
/* Arrays to be sorted */
ulint uarr[100000];
ulint aux_uarr[100000];
dulint duarr[100000];
dulint aux_duarr[100000];
/*********************************************************************
Tests for two-way lists. */
void
test1(void)
/*=======*/
{
ulint i;
UT_LIST_BASE_NODE_T(node_t) base1;
UT_LIST_BASE_NODE_T(node_t) base2;
node_t* node;
node_t* node2;
printf("-------------------------------------------\n");
printf("TEST 1. Test of two-way lists \n");
UT_LIST_INIT(base1);
UT_LIST_INIT(base2);
for (i = 0; i < 1000; i++) {
node = ut_malloc(sizeof(node_t));
node->index = 999 - i;
UT_LIST_ADD_FIRST(list1, base1, node);
UT_LIST_ADD_LAST(list2, base2, node);
}
UT_LIST_VALIDATE(list1, node_t, base1);
UT_LIST_VALIDATE(list2, node_t, base2);
node = UT_LIST_GET_FIRST(base1);
for (i = 0; i < 1000; i++) {
ut_a(node);
ut_a(node->index == i);
node = UT_LIST_GET_NEXT(list1, node);
}
ut_a(node == NULL);
node = UT_LIST_GET_FIRST(base2);
for (i = 0; i < 1000; i++) {
ut_a(node);
ut_a(node->index == 999 - i);
node = UT_LIST_GET_NEXT(list2, node);
}
ut_a(node == NULL);
UT_LIST_VALIDATE(list1, node_t, base1);
UT_LIST_VALIDATE(list2, node_t, base2);
node = UT_LIST_GET_FIRST(base1);
for (i = 0; i < 500; i++) {
ut_a(node);
ut_a(node->index == i);
node = UT_LIST_GET_NEXT(list1, node);
}
for (i = 0; i < 100; i++) {
node2 = ut_malloc(sizeof(node_t));
node2->index = 99 - i;
UT_LIST_INSERT_AFTER(list1, base1, node, node2);
UT_LIST_VALIDATE(list1, node_t, base1);
}
node2 = ut_malloc(sizeof(node_t));
node2->index = 1000;
UT_LIST_INSERT_AFTER(list1, base1, UT_LIST_GET_LAST(base1), node2);
node2 = node;
for (i = 0; i < 100; i++) {
node2 = UT_LIST_GET_NEXT(list1, node2);
ut_a(node2);
ut_a(node2->index == i);
}
UT_LIST_VALIDATE(list1, node_t, base1);
for (i = 0; i < 600; i++) {
node2 = UT_LIST_GET_NEXT(list1, node);
UT_LIST_REMOVE(list1, base1, node2);
UT_LIST_VALIDATE(list1, node_t, base1);
}
node2 = UT_LIST_GET_NEXT(list1, node);
UT_LIST_VALIDATE(list1, node_t, base1);
UT_LIST_VALIDATE(list2, node_t, base2);
ut_a(UT_LIST_GET_LEN(base1) == 501);
ut_a(UT_LIST_GET_LAST(base1) == node);
for (i = 0; i < 500; i++) {
node = UT_LIST_GET_PREV(list1, node);
}
ut_a(UT_LIST_GET_FIRST(base1) == node);
for (i = 0; i < 501; i++) {
node2 = UT_LIST_GET_FIRST(base1);
UT_LIST_REMOVE(list1, base1, node2);
}
UT_LIST_VALIDATE(list1, node_t, base1);
UT_LIST_VALIDATE(list2, node_t, base2);
ut_a(UT_LIST_GET_LEN(base1) == 0);
ut_a(UT_LIST_GET_LEN(base2) == 1000);
}
/*********************************************************************
Tests for dulints. */
void
test2(void)
/*=======*/
{
dulint a, b;
printf("-------------------------------------------\n");
printf("TEST 2. Test of dulints \n");
a = ut_dulint_create(0xFFFFFFFF, 0xFFFFFFFF);
b = a;
ut_a(ut_dulint_cmp(a, b) == 0);
ut_a(ut_dulint_get_low(b) == 0xFFFFFFFF);
ut_a(ut_dulint_get_high(b) == 0xFFFFFFFF);
a = ut_dulint_create(0xFFFFFFFE, 0xFFFFFFFF);
ut_a(ut_dulint_cmp(a, b) == -1);
ut_a(ut_dulint_cmp(b, a) == 1);
a = ut_dulint_create(0xFFFFFFFF, 0xFFFFFFFE);
ut_a(ut_dulint_cmp(a, b) == -1);
ut_a(ut_dulint_cmp(b, a) == 1);
a = ut_dulint_create(5, 0xFFFFFFFF);
a = ut_dulint_add(a, 5);
ut_a(ut_dulint_get_low(a) == 4);
ut_a(ut_dulint_get_high(a) == 6);
a = ut_dulint_create(5, 0x80000000);
a = ut_dulint_add(a, 0x80000000);
ut_a(ut_dulint_get_low(a) == 0);
ut_a(ut_dulint_get_high(a) == 6);
a = ut_dulint_create(5, 10);
a = ut_dulint_add(a, 20);
ut_a(ut_dulint_get_low(a) == 30);
ut_a(ut_dulint_get_high(a) == 5);
}
/***************************************************************
Comparison function for ulints. */
UNIV_INLINE
int
cmp_ulint(ulint a, ulint b)
/*=======================*/
{
if (a < b) {
return(-1);
} else if (b < a) {
return(1);
} else {
return(0);
}
}
/****************************************************************
Sort function for ulint arrays. */
void
sort_ulint(ulint* arr, ulint* aux_arr, ulint low, ulint high)
/*=========================================================*/
{
ut_ad(high <= 100000);
UT_SORT_FUNCTION_BODY(sort_ulint, arr, aux_arr, low, high,
cmp_ulint);
}
/****************************************************************
Sort function for dulint arrays. */
void
sort_dulint(dulint* arr, dulint* aux_arr, ulint low, ulint high)
/*=========================================================*/
{
ut_ad(high <= 100000);
UT_SORT_FUNCTION_BODY(sort_dulint, arr, aux_arr, low, high,
ut_dulint_cmp);
}
/*********************************************************************
Tests for sorting. */
void
test3(void)
/*=======*/
{
ulint i, j;
ulint tm, oldtm;
printf("-------------------------------------------\n");
printf("TEST 3. Test of sorting \n");
for (i = 0; i < 100000; i++) {
uarr[i] = ut_rnd_gen_ulint();
}
oldtm = ut_clock();
for (j = 0; j < 1; j++) {
i = 100000;
sort_ulint(uarr, aux_uarr, 0, i);
}
tm = ut_clock();
printf("Wall clock time for sort of %lu ulints %lu millisecs\n",
j * i, tm - oldtm);
for (i = 1; i < 100000; i++) {
ut_a(uarr[i - 1] < uarr[i]);
}
for (i = 0; i < 100000; i++) {
uarr[i] = 99999 - i;
}
sort_ulint(uarr, aux_uarr, 0, 100000);
for (i = 1; i < 100000; i++) {
ut_a(uarr[i] == i);
}
sort_ulint(uarr, aux_uarr, 0, 100000);
for (i = 1; i < 100000; i++) {
ut_a(uarr[i] == i);
}
sort_ulint(uarr, aux_uarr, 5, 6);
for (i = 1; i < 100000; i++) {
ut_a(uarr[i] == i);
}
for (i = 0; i < 100000; i++) {
uarr[i] = 5;
}
sort_ulint(uarr, aux_uarr, 0, 100000);
for (i = 1; i < 100000; i++) {
ut_a(uarr[i] == 5);
}
for (i = 0; i < 100000; i++) {
duarr[i] = ut_dulint_create(ut_rnd_gen_ulint() & 0xFFFFFFFF,
ut_rnd_gen_ulint() & 0xFFFFFFFF);
}
oldtm = ut_clock();
i = 100000;
sort_dulint(duarr, aux_duarr, 0, i);
tm = ut_clock();
printf("Wall clock time for sort of %lu dulints %lu millisecs\n",
j * i, tm - oldtm);
for (i = 1; i < 100000; i++) {
ut_a(ut_dulint_cmp(duarr[i - 1], duarr[i]) < 0);
}
}
void
main(void)
{
test1();
test2();
test3();
printf("TEST SUCCESSFULLY COMPLETED!\n");
}

View File

@ -316,7 +316,7 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
char **arg_unix_socket) char **arg_unix_socket)
{ {
HANDLE hPipe=INVALID_HANDLE_VALUE; HANDLE hPipe=INVALID_HANDLE_VALUE;
char szPipeName [ 257 ]; char szPipeName [ 1024 ];
DWORD dwMode; DWORD dwMode;
int i; int i;
my_bool testing_named_pipes=0; my_bool testing_named_pipes=0;
@ -327,9 +327,9 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
if (!host || !strcmp(host,LOCAL_HOST)) if (!host || !strcmp(host,LOCAL_HOST))
host=LOCAL_HOST_NAMEDPIPE; host=LOCAL_HOST_NAMEDPIPE;
sprintf( szPipeName, "\\\\%s\\pipe\\%s", host, unix_socket); strxnmov(szPipeName, sizeof(szPipeName), "\\\\", host, "\\pipe\\",
DBUG_PRINT("info",("Server name: '%s'. Named Pipe: %s", unix_socket, NullS);
host, unix_socket)); DBUG_PRINT("info",("Server name: '%s'. Named Pipe: %s", host, unix_socket));
for (i=0 ; i < 100 ; i++) /* Don't retry forever */ for (i=0 ; i < 100 ; i++) /* Don't retry forever */
{ {
@ -694,7 +694,7 @@ mysql_debug(const char *debug __attribute__((unused)))
#else #else
{ {
char buff[80]; char buff[80];
strmov(strmov(buff,"libmysql: "),env); strxnmov(buff,sizeof(buff),"libmysql: ", env);
MessageBox((HWND) 0,"Debugging variable MYSQL_DEBUG used",buff,MB_OK); MessageBox((HWND) 0,"Debugging variable MYSQL_DEBUG used",buff,MB_OK);
} }
#endif #endif
@ -1746,7 +1746,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
(unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE))) (unix_socket && !strcmp(unix_socket,MYSQL_NAMEDPIPE)))
{ {
net->last_errno= CR_SERVER_LOST; net->last_errno= CR_SERVER_LOST;
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
goto error; /* User only requested named pipes */ goto error; /* User only requested named pipes */
} }
/* Try also with TCP/IP */ /* Try also with TCP/IP */
@ -1832,7 +1832,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
vio_poll_read(net->vio, mysql->options.connect_timeout)) vio_poll_read(net->vio, mysql->options.connect_timeout))
{ {
net->last_errno= CR_SERVER_LOST; net->last_errno= CR_SERVER_LOST;
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
goto error; goto error;
} }
if ((pkt_length=net_safe_read(mysql)) == packet_error) if ((pkt_length=net_safe_read(mysql)) == packet_error)
@ -1984,7 +1984,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (my_net_write(net,buff,(uint) (2)) || net_flush(net)) if (my_net_write(net,buff,(uint) (2)) || net_flush(net))
{ {
net->last_errno= CR_SERVER_LOST; net->last_errno= CR_SERVER_LOST;
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
goto error; goto error;
} }
/* Do the SSL layering. */ /* Do the SSL layering. */
@ -1996,7 +1996,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
options->ssl_cipher))) options->ssl_cipher)))
{ {
net->last_errno= CR_SSL_CONNECTION_ERROR; net->last_errno= CR_SSL_CONNECTION_ERROR;
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
goto error; goto error;
} }
DBUG_PRINT("info", ("IO layer change in progress...")); DBUG_PRINT("info", ("IO layer change in progress..."));
@ -2036,7 +2036,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net)) if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net))
{ {
net->last_errno= CR_SERVER_LOST; net->last_errno= CR_SERVER_LOST;
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
goto error; goto error;
} }
if (net_safe_read(mysql) == packet_error) if (net_safe_read(mysql) == packet_error)

View File

@ -133,7 +133,7 @@ MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
if (!hp) if (!hp)
{ {
con->last_errno=tmp_errno; con->last_errno=tmp_errno;
sprintf(con->last_error,"Could not resolve host '%s'",host); sprintf(con->last_error,"Could not resolve host '%-.64s'",host);
my_gethostbyname_r_free(); my_gethostbyname_r_free();
goto err; goto err;
} }

View File

@ -124,11 +124,11 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
#ifdef OS2 #ifdef OS2
/* changing environ variable doesn't work with VACPP */ /* changing environ variable doesn't work with VACPP */
char buffer[256]; char buffer[256];
sprintf( buffer, "TMP=%s", dir); strxnmov(buffer, sizeof(buffer), "TMP=", dir);
/* remove ending backslash */ /* remove ending backslash */
if (buffer[strlen(buffer)-1] == '\\') if (buffer[strlen(buffer)-1] == '\\')
buffer[strlen(buffer)-1] = '\0'; buffer[strlen(buffer)-1] = '\0';
putenv( buffer); putenv(buffer);
#elif !defined(__NETWARE__) #elif !defined(__NETWARE__)
old_env= (char**) environ; old_env= (char**) environ;
if (dir) if (dir)
@ -138,7 +138,7 @@ File create_temp_file(char *to, const char *dir, const char *prefix,
} }
#endif #endif
if ((res=tempnam((char*) dir, (char*) prefix))) if ((res=tempnam((char*) dir, (char*) prefix)))
{ {
strmake(to,res,FN_REFLEN-1); strmake(to,res,FN_REFLEN-1);
(*free)(res); (*free)(res);
file=my_create(to,0, file=my_create(to,0,

View File

@ -106,7 +106,7 @@ my_string my_tempnam(const char *dir, const char *pfx,
#ifdef OS2 #ifdef OS2
/* changing environ variable doesn't work with VACPP */ /* changing environ variable doesn't work with VACPP */
char buffer[256]; char buffer[256];
sprintf( buffer, "TMP=%s", dir); strxnmov(buffer, sizeof(buffer), "TMP=", dir);
/* remove ending backslash */ /* remove ending backslash */
if (buffer[strlen(buffer)-1] == '\\') if (buffer[strlen(buffer)-1] == '\\')
buffer[strlen(buffer)-1] = '\0'; buffer[strlen(buffer)-1] = '\0';

View File

@ -202,7 +202,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
open_flags |= O_RDWR; open_flags |= O_RDWR;
else else
open_flags |= O_WRONLY; open_flags |= O_WRONLY;
db[0]=0; db[0]=0;
open_count++; open_count++;
if ((file=my_open(log_file_name,open_flags, if ((file=my_open(log_file_name,open_flags,
@ -215,12 +215,15 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
case LOG_NORMAL: case LOG_NORMAL:
{ {
char *end; char *end;
int len=my_snprintf(buff, sizeof(buff),
#ifdef __NT__ #ifdef __NT__
sprintf(buff, "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n", my_progname, server_version, mysql_port, mysql_unix_port); "%s, Version: %s, started with:\nTCP Port: %d, Named Pipe: %s\n",
#else #else
sprintf(buff, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysql_port,mysql_unix_port); "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n",
#endif #endif
end=strmov(strend(buff),"Time Id Command Argument\n"); my_progname, server_version, mysql_port, mysql_unix_port);
end=strnmov(buff+len,"Time Id Command Argument\n",
sizeof(buff)-len);
if (my_b_write(&log_file, (byte*) buff,(uint) (end-buff)) || if (my_b_write(&log_file, (byte*) buff,(uint) (end-buff)) ||
flush_io_cache(&log_file)) flush_io_cache(&log_file))
goto err; goto err;
@ -231,7 +234,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
time_t skr=time(NULL); time_t skr=time(NULL);
struct tm tm_tmp; struct tm tm_tmp;
localtime_r(&skr,&tm_tmp); localtime_r(&skr,&tm_tmp);
sprintf(buff,"# %s, Version: %s at %02d%02d%02d %2d:%02d:%02d\n", my_snprintf(buff,sizeof(buff),"# %s, Version: %s at %02d%02d%02d %2d:%02d:%02d\n",
my_progname,server_version, my_progname,server_version,
tm_tmp.tm_year % 100, tm_tmp.tm_year % 100,
tm_tmp.tm_mon+1, tm_tmp.tm_mon+1,
@ -254,7 +257,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg,
index_file_name_arg= name; // Use same basename for index file index_file_name_arg= name; // Use same basename for index file
opt= MY_UNPACK_FILENAME | MY_REPLACE_EXT; opt= MY_UNPACK_FILENAME | MY_REPLACE_EXT;
} }
if (!my_b_filelength(&log_file)) if (!my_b_filelength(&log_file))
{ {
/* /*

View File

@ -117,7 +117,7 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
char **arg_unix_socket) char **arg_unix_socket)
{ {
HANDLE hPipe=INVALID_HANDLE_VALUE; HANDLE hPipe=INVALID_HANDLE_VALUE;
char szPipeName [ 257 ]; char szPipeName [512];
DWORD dwMode; DWORD dwMode;
int i; int i;
my_bool testing_named_pipes=0; my_bool testing_named_pipes=0;
@ -126,7 +126,8 @@ HANDLE create_named_pipe(NET *net, uint connect_timeout, char **arg_host,
if (!host || !strcmp(host,LOCAL_HOST)) if (!host || !strcmp(host,LOCAL_HOST))
host=LOCAL_HOST_NAMEDPIPE; host=LOCAL_HOST_NAMEDPIPE;
sprintf( szPipeName, "\\\\%s\\pipe\\%s", host, unix_socket); strxnmov(szPipeName, sizeof(szPipeName), "\\\\", host, "\\pipe\\",
unix_socket, NullS);
DBUG_PRINT("info",("Server name: '%s'. Named Pipe: %s", DBUG_PRINT("info",("Server name: '%s'. Named Pipe: %s",
host, unix_socket)); host, unix_socket));

View File

@ -189,7 +189,7 @@ static const char* default_dbug_option=IF_WIN("d:t:i:O,\\mysqld.trace",
#endif #endif
#ifdef __NT__ #ifdef __NT__
static char szPipeName [ 257 ]; static char szPipeName [512];
static SECURITY_ATTRIBUTES saPipeSecurity; static SECURITY_ATTRIBUTES saPipeSecurity;
static SECURITY_DESCRIPTOR sdPipeDescriptor; static SECURITY_DESCRIPTOR sdPipeDescriptor;
static HANDLE hPipe = INVALID_HANDLE_VALUE; static HANDLE hPipe = INVALID_HANDLE_VALUE;
@ -1173,7 +1173,8 @@ static void server_init(void)
if (Service.IsNT() && mysql_unix_port[0] && !opt_bootstrap && if (Service.IsNT() && mysql_unix_port[0] && !opt_bootstrap &&
opt_enable_named_pipe) opt_enable_named_pipe)
{ {
sprintf( szPipeName, "\\\\.\\pipe\\%s", mysql_unix_port ); strxnmov(szPipeName, sizeof(szPipeName), "\\\\.\\pipe\\",
unix_socket, NullS);
ZeroMemory( &saPipeSecurity, sizeof(saPipeSecurity) ); ZeroMemory( &saPipeSecurity, sizeof(saPipeSecurity) );
ZeroMemory( &sdPipeDescriptor, sizeof(sdPipeDescriptor) ); ZeroMemory( &sdPipeDescriptor, sizeof(sdPipeDescriptor) );
if ( !InitializeSecurityDescriptor(&sdPipeDescriptor, if ( !InitializeSecurityDescriptor(&sdPipeDescriptor,