⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tsrecv97.c

📁 Mysql for Windows最新源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	que_graph_publish(fork, trx->sess);	trx->graph = fork;	mutex_exit(&kernel_mutex);	oldtm = ut_clock();	rnd += 78667;	for (i = 0; i < *((ulint*)arg); i++) {		rnd = (rnd - 1) % 500;				dtuple_gen_test_tuple3(row, rnd, DTUPLE_TEST_RND30, 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);	}	tm = ut_clock();	printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm);	/*-------------------------------------*/	/* ROLLBACK */		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(3000000);	/*-------------------------------------*/#ifdef notdefined	/* 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);#endif		/*-------------------------------------*/	count++;	mem_print_info();	if (count < COUNT) {		goto loop;	}	return(0);}/*********************************************************************Test for updates. */ulinttest3(/*==*/	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;	ulint		rnd;	dtuple_t*	row;	dtuple_t*	entry;	byte		buf[100];	ulint		count = 0;	btr_pcur_t	pcur;	upd_t*		update;	upd_field_t*	ufield;	dict_tree_t*	tree;	dict_index_t*	index;	mtr_t		mtr;	upd_node_t*	node;	byte*		ptr;	ulint		len;	ulint		err;	UT_NOT_USED(arg);		printf("-------------------------------------------------\n");	printf("TEST 3. UPDATES\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));		/*-------------------------------------*/	/* 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);		thr->child = ins_node_create(fork, thr, row, table, heap);	mutex_enter(&kernel_mutex);		que_graph_publish(fork, trx->sess);	trx->graph = fork;	mutex_exit(&kernel_mutex);	rnd = 0;	oldtm = ut_clock();	for (i = 0; i < 3; i++) {		dtuple_gen_test_tuple3(row, i, DTUPLE_TEST_RND30, 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);	}	tm = ut_clock();	printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm);	/*-------------------------------------*/	/* 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);	dict_table_print_by_name("TS_TABLE1");	/*-------------------------------------*/	/* UPDATE ROWS */	ut_a(trx_start(trx, ULINT_UNDEFINED));		fork = que_fork_create(NULL, NULL, QUE_FORK_UPDATE, 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);		update = upd_create(1, heap);	node = upd_node_create(fork, thr, table, &pcur, update, heap);	thr->child = node;	node->cmpl_info = 0;	mutex_enter(&kernel_mutex);	que_graph_publish(fork, trx->sess);	trx->graph = fork;	mutex_exit(&kernel_mutex);	dtuple_gen_test_tuple3(row, 1, DTUPLE_TEST_RND30, buf);	entry = dtuple_create(heap, 2);	dfield_copy(dtuple_get_nth_field(entry, 0),					dtuple_get_nth_field(row, 0));	dfield_copy(dtuple_get_nth_field(entry, 1),					dtuple_get_nth_field(row, 1));	index = dict_table_get_first_index(table);	tree = dict_index_get_tree(index);	btr_pcur_set_mtr(&pcur, &mtr);		mtr_start(&mtr);		btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_SEARCH_LEAF, &pcur, &mtr);	btr_pcur_store_position(&pcur, &mtr);	err = lock_clust_rec_read_check_and_lock(0, btr_pcur_get_rec(&pcur),							index, LOCK_X, thr);	ut_a(err == DB_SUCCESS);		btr_pcur_commit(&pcur);		ufield = upd_get_nth_field(update, 0);	upd_field_set_col_no(ufield, 2, table);	dfield_set_data(&(ufield->new_val), "updated field", 14);	mutex_enter(&kernel_mutex);		ut_a(	thr == que_fork_start_command(fork, SESS_COMM_EXECUTE, 0));	mutex_exit(&kernel_mutex);	que_run_threads(thr);	mtr_start(&mtr);	ut_a(btr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr));	ptr = rec_get_nth_field(btr_pcur_get_rec(&pcur), 5, &len);	ut_a(ut_memcmp(ptr, "updated field", 14) == 0);	btr_pcur_commit(&pcur);	dict_table_print_by_name("TS_TABLE1");	ufield = upd_get_nth_field(update, 0);	upd_field_set_col_no(ufield, 0, table);	dfield_set_data(&(ufield->new_val), "31415926", 9);	mutex_enter(&kernel_mutex);		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("TS_TABLE1");	/*-------------------------------------*/	/* ROLLBACK */#ifdef notdefined		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 updates %lu milliseconds\n",		i, tm - oldtm);	/*-------------------------------------*/	/* 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);	/*-------------------------------------*/#endif	dict_table_print_by_name("TS_TABLE1");	count++;	if (count < 1) {		goto loop;	}	return(0);}/*********************************************************************Init for update test. */ulinttest4_1(void)/*=========*/{	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;	ulint		rnd;	dtuple_t*	row;	byte		buf[100];	printf("-------------------------------------------------\n");	printf("TEST 4.1. UPDATE INIT\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));		/*-------------------------------------*/	/* 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);		thr->child = ins_node_create(fork, thr, row, table, heap);	mutex_enter(&kernel_mutex);		que_graph_publish(fork, trx->sess);	trx->graph = fork;	mutex_exit(&kernel_mutex);	rnd = 0;	oldtm = ut_clock();	for (i = 0; i < 200; i++) {				dtuple_gen_test_tuple3(row, i, 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);	}	tm = ut_clock();	printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm);	/*-------------------------------------*/	/* 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);	dict_table_print_by_name("TS_TABLE1");	return(0);}/*************************************************************************Checks that the multithreaded update test has rolled back its updates. */voidtest4_2(void)/*=========*/{	dtuple_t*	entry;	mem_heap_t*	heap;	mem_heap_t*	heap2;	mtr_t		mtr;	byte		buf[32];	sess_t*		sess;	com_endpoint_t*	com_endpoint;	que_fork_t*	fork;	dict_table_t*	table;	dict_index_t*	index;	dict_tree_t*	tree;	que_thr_t*	thr;	trx_t*		trx;	ulint		i;	dtuple_t*	row;	btr_pcur_t	pcur;	rec_t*		rec;		printf("-------------------------------------------------\n");	printf("TEST 4.2. CHECK UPDATE RESULT\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_table_get("TS_TABLE1", trx);	index = dict_table_get_first_index(table);		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 < 200; i++) {		ut_a(btr_pcur_move_to_next(&pcur, &mtr));		dtuple_gen_search_tuple3(entry, i, buf);		rec = btr_pcur_get_rec(&pcur);				ut_a(0 == cmp_dtuple_rec(entry, rec));		heap2 = mem_heap_create(200);				row = row_build(ROW_COPY_DATA, index, rec, heap2);		ut_a(30 == dfield_get_len(dtuple_get_nth_field(row, 2)));		ut_a(0 == ut_memcmp(			dfield_get_data(dtuple_get_nth_field(row, 2)),			"12345678901234567890123456789", 30));		mem_heap_free(heap2);	}		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);		/*-------------------------------------*/	/* 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);	que_run_threads(thr);}/*********************************************************************Test for massive updates. */ulinttest4mt(/*====*/	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;	ulint		rnd;	dtuple_t*	entry;	byte		buf[100];	byte		buf2[4000];	ulint		count = 0;	btr_pcur_t	pcur;	upd_t*		update;	upd_field_t*	ufield;	dict_tree_t*	tree;	dict_index_t*	index;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -