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

📄 tsrecv97.c

📁 Mysql for Windows最新源码
💻 C
📖 第 1 页 / 共 5 页
字号:
	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"); */	return(0);}/*********************************************************************Another test for table creation. */ulinttest1_7(/*====*/	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.7. CREATE TABLE WITH 12 COLUMNS AND WITH 1 INDEX\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_TABLE4", 0, 12);	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);	dict_mem_table_add_col(table, "COL4", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL5", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL6", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL7", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL8", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL9", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL10", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL11", DATA_VARCHAR,						DATA_ENGLISH, 100, 0);	dict_mem_table_add_col(table, "COL12", 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_TABLE4", "IND1", 0,					DICT_CLUSTERED | DICT_UNIQUE, 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"); */	return(0);}/*********************************************************************Test for inserts. */ulinttest2(/*==*/	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;	dict_tree_t*	tree;	que_thr_t*	thr;	trx_t*		trx;	ulint		i;	ulint		rnd;	dtuple_t*	row;	byte		buf[100];	ulint		count = 0;	ins_node_t*	node;	dict_index_t*	index;/*	ulint		size; */	dtuple_t*	entry;	btr_pcur_t	pcur;	mtr_t		mtr;		printf("-------------------------------------------------\n");	printf("TEST 2. MASSIVE 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));		btr_search_print_info();	/*-------------------------------------*/	/* MASSIVE RANDOM 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;	oldtm = ut_clock();	for (i = 0; i < *((ulint*)arg); i++) {		rnd = (rnd + 7857641) % 200000;				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);		if (i % 1000 == 0) {			printf(		"********************************Inserted %lu rows\n", i);			ibuf_print();		}	}	tm = ut_clock();	printf("Wall time for %lu inserts %lu milliseconds\n", i, tm - oldtm);/*	for (i = 0; i < 10; i++) {		size = ibuf_contract(TRUE);				printf("%lu bytes will be contracted\n", size);		os_thread_sleep(1000000);	}*/	index = dict_table_get_next_index(dict_table_get_first_index(table));	tree = dict_index_get_tree(index);	btr_validate_tree(tree);	index = dict_table_get_next_index(index);	tree = dict_index_get_tree(index);	btr_validate_tree(tree);/*	dict_table_print_by_name("TS_TABLE1"); */	btr_search_print_info();	/* Check inserted entries */	rnd = 0;	entry = dtuple_create(heap, 1);	for (i = 0; i < *((ulint*)arg); i++) {		rnd = (rnd +  7857641) % 200000;		dtuple_gen_search_tuple3(entry, rnd, buf);		index = dict_table_get_first_index(table);		tree = dict_index_get_tree(index);		mtr_start(&mtr);			btr_pcur_open(index, entry, PAGE_CUR_LE, BTR_SEARCH_LEAF, &pcur,									&mtr);		ut_a(0 == cmp_dtuple_rec(entry, btr_pcur_get_rec(&pcur)));		btr_pcur_close(&pcur);		mtr_commit(&mtr);	}	btr_validate_tree(tree);/*	btr_print_tree(tree, 5); */	/*-------------------------------------*/	/* 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(1000000);	btr_validate_tree(tree);/*	btr_search_print_info();	dict_table_print_by_name("TS_TABLE1"); */	/*-------------------------------------*/#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++;	if (count < 1) {		goto loop;	}	mem_heap_free(heap);	return(0);}/*********************************************************************Another test for inserts. */ulinttest2_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_tree_t*	tree;	dict_index_t*	index;	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;	rnd = 0;	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);	oldtm = ut_clock();	for (i = 0; i < *((ulint*)arg); i++) {		dtuple_gen_test_tuple3(row, rnd, DTUPLE_TEST_RND3500, 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);#ifdef notdefined/*	dict_table_print_by_name("TS_TABLE1"); */	ibuf_print();	index = dict_table_get_first_index(table);	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));	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	#ifdef notdefined	/*-------------------------------------*/	/* ROLLBACK */	/*	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);	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 < 5) {		goto loop;	}	mem_heap_free(heap);

⌨️ 快捷键说明

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