diff options
author | unknown <marko@hundin.mysql.fi> | 2004-02-19 14:37:39 +0200 |
---|---|---|
committer | unknown <marko@hundin.mysql.fi> | 2004-02-19 14:37:39 +0200 |
commit | 731fd9c5e049d152f3f08967e3730bd16027a834 (patch) | |
tree | 5f0c934534bbc8a4f473a6561d8e43043f469049 /innobase/usr | |
parent | f509ce23d6967d72add3169496acdbe5bf752061 (diff) | |
download | mariadb-git-731fd9c5e049d152f3f08967e3730bd16027a834.tar.gz |
Remove unnecessary files and functions
innobase/srv/srv0srv.c:
Removed unused code
BitKeeper/deleted/.del-FSP0FSP.C~f1c7e596cadd429:
Delete: innobase/fsp/trash/FSP0FSP.C
BitKeeper/deleted/.del-log0trsh.c~ebdd6ce463d8bf0:
Delete: innobase/log/trash/log0trsh.c
BitKeeper/deleted/.del-os0fileold.c~7be518438162e2f:
Delete: innobase/os/os0fileold.c
innobase/include/usr0sess.h:
Remove unused functions
innobase/lock/lock0lock.c:
Remove commented-out call to deleted function sess_raise_error_low()
innobase/trx/trx0trx.c:
Remove commented-out or unreachable calls to deleted function sess_raise_error_low()
innobase/usr/usr0sess.c:
Remove unused functions
Diffstat (limited to 'innobase/usr')
-rw-r--r-- | innobase/usr/usr0sess.c | 604 |
1 files changed, 8 insertions, 596 deletions
diff --git a/innobase/usr/usr0sess.c b/innobase/usr/usr0sess.c index 0335c8046e2..c024a51b0f4 100644 --- a/innobase/usr/usr0sess.c +++ b/innobase/usr/usr0sess.c @@ -29,6 +29,13 @@ Created 6/25/1996 Heikki Tuuri 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 TRUE, puts the session to error state and does not try to send the error message. */ @@ -85,42 +92,6 @@ sess_cli_msg_set_sess( 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. */ UNIV_INLINE @@ -311,6 +282,7 @@ sess_open( /************************************************************************* Closes a session, freeing the memory occupied by it. */ +static void sess_close( /*=======*/ @@ -595,330 +567,6 @@ sess_error_low( 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 to the client. */ @@ -936,239 +584,3 @@ sess_command_completed_message( SESS_RELEASE_KERNEL); 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); -} |