diff options
author | unknown <konstantin@mysql.com> | 2005-06-08 19:57:26 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2005-06-08 19:57:26 +0400 |
commit | 8aba6f29cb8b09c863c271f89f13611c11927cb0 (patch) | |
tree | 97000f69e01d70ceaf0ae26037892e92f769d745 /sql | |
parent | 60a5939f565077e4e57ec512139ca86aa0f06364 (diff) | |
download | mariadb-git-8aba6f29cb8b09c863c271f89f13611c11927cb0.tar.gz |
Trim trailing spaces.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_prepare.cc | 208 |
1 files changed, 104 insertions, 104 deletions
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 1d1ea37a15b..cb96f57a58a 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -15,18 +15,18 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /********************************************************************** -This file contains the implementation of prepare and executes. +This file contains the implementation of prepare and executes. Prepare: - - Server gets the query from client with command 'COM_PREPARE'; + - Server gets the query from client with command 'COM_PREPARE'; in the following format: [COM_PREPARE:1] [query] - - Parse the query and recognize any parameter markers '?' and + - Parse the query and recognize any parameter markers '?' and store its information list in lex->param_list - - Allocate a new statement for this prepare; and keep this in + - Allocate a new statement for this prepare; and keep this in 'thd->prepared_statements' pool. - - Without executing the query, return back to client the total + - Without executing the query, return back to client the total number of parameters along with result-set metadata information (if any) in the following format: [STMT_ID:4] @@ -34,10 +34,10 @@ Prepare: [Param_count:2] [Columns meta info] (if Column_count > 0) [Params meta info] (if Param_count > 0 ) (TODO : 4.1.1) - + Prepare-execute: - - Server gets the command 'COM_EXECUTE' to execute the + - Server gets the command 'COM_EXECUTE' to execute the previously prepared query. If there is any param markers; then client will send the data in the following format: [COM_EXECUTE:1] @@ -45,12 +45,12 @@ Prepare-execute: [NULL_BITS:(param_count+7)/8)] [TYPES_SUPPLIED_BY_CLIENT(0/1):1] [[length]data] - [[length]data] .. [[length]data]. - (Note: Except for string/binary types; all other types will not be + [[length]data] .. [[length]data]. + (Note: Except for string/binary types; all other types will not be supplied with length field) - - Replace the param items with this new data. If it is a first execute + - Replace the param items with this new data. If it is a first execute or types altered by client; then setup the conversion routines. - - Execute the query without re-parsing and send back the results + - Execute the query without re-parsing and send back the results to client Long data handling: @@ -61,8 +61,8 @@ Long data handling: - data from the packet is appended to long data value buffer for this placeholder. - It's up to the client to check for read data ended. The server doesn't - care; and also server doesn't notify to the client that it got the - data or not; if there is any error; then during execute; the error + care; and also server doesn't notify to the client that it got the + data or not; if there is any error; then during execute; the error will be returned ***********************************************************************/ @@ -97,7 +97,7 @@ public: #else bool (*set_params_data)(Prepared_statement *st, String *expanded_query); #endif - bool (*set_params_from_vars)(Prepared_statement *stmt, + bool (*set_params_from_vars)(Prepared_statement *stmt, List<LEX_STRING>& varnames, String *expanded_query); public: @@ -167,7 +167,7 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) Send types and names of placeholders to the client XXX: fix this nasty upcast from List<Item_param> to List<Item> */ - DBUG_RETURN(my_net_write(net, buff, sizeof(buff)) || + DBUG_RETURN(my_net_write(net, buff, sizeof(buff)) || (stmt->param_count && stmt->thd->protocol_simple.send_fields((List<Item> *) &stmt->lex->param_list, @@ -220,7 +220,7 @@ static ulong get_param_length(uchar **packet, ulong len) } if (len < 5) return 0; - (*packet)+=9; // Must be 254 when here + (*packet)+=9; // Must be 254 when here /* In our client-server protocol all numbers bigger than 2^24 stored as 8 bytes with uint8korr. Here we always know that @@ -242,7 +242,7 @@ static ulong get_param_length(uchar **packet, ulong len) pos input data buffer len length of data in the buffer - All these functions read the data from pos, convert it to requested type + All these functions read the data from pos, convert it to requested type and assign to param; pos is advanced to predefined length. Make a note that the NULL handling is examined at first execution @@ -260,7 +260,7 @@ static void set_param_tiny(Item_param *param, uchar **pos, ulong len) return; #endif int8 value= (int8) **pos; - param->set_int(param->unsigned_flag ? (longlong) ((uint8) value) : + param->set_int(param->unsigned_flag ? (longlong) ((uint8) value) : (longlong) value, 4); *pos+= 1; } @@ -480,7 +480,7 @@ static void set_param_str(Item_param *param, uchar **pos, ulong len) } -#undef get_param_length +#undef get_param_length static void setup_one_conversion_function(THD *thd, Item_param *param, uchar param_type) @@ -583,12 +583,12 @@ static void setup_one_conversion_function(THD *thd, Item_param *param, #ifndef EMBEDDED_LIBRARY /* - Update the parameter markers by reading data from client packet + Update the parameter markers by reading data from client packet and if binary/update log is set, generate the valid query. */ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, - uchar *read_pos, uchar *data_end, + uchar *read_pos, uchar *data_end, String *query) { THD *thd= stmt->thd; @@ -596,14 +596,14 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, Item_param **end= begin + stmt->param_count; uint32 length= 0; - String str; + String str; const String *res; - DBUG_ENTER("insert_params_withlog"); + DBUG_ENTER("insert_params_withlog"); if (query->copy(stmt->query, stmt->query_length, default_charset_info)) DBUG_RETURN(1); - + for (Item_param **it= begin; it < end; ++it) { Item_param *param= *it; @@ -624,7 +624,7 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, if (query->replace(param->pos_in_query+length, 1, *res)) DBUG_RETURN(1); - + length+= res->length()-1; } DBUG_RETURN(0); @@ -632,13 +632,13 @@ static bool insert_params_withlog(Prepared_statement *stmt, uchar *null_array, static bool insert_params(Prepared_statement *stmt, uchar *null_array, - uchar *read_pos, uchar *data_end, + uchar *read_pos, uchar *data_end, String *expanded_query) { Item_param **begin= stmt->param_array; Item_param **end= begin + stmt->param_count; - DBUG_ENTER("insert_params"); + DBUG_ENTER("insert_params"); for (Item_param **it= begin; it < end; ++it) { @@ -672,7 +672,7 @@ static bool setup_conversion_functions(Prepared_statement *stmt, if (*read_pos++) //types supplied / first execute { /* - First execute or types altered by the client, setup the + First execute or types altered by the client, setup the conversion routines for all parameters (one time) */ Item_param **it= stmt->param_array; @@ -720,8 +720,8 @@ static bool emb_insert_params(Prepared_statement *stmt, String *expanded_query) uchar *buff= (uchar*) client_param->buffer; param->unsigned_flag= client_param->is_unsigned; param->set_param_func(param, &buff, - client_param->length ? - *client_param->length : + client_param->length ? + *client_param->length : client_param->buffer_length); } } @@ -747,7 +747,7 @@ static bool emb_insert_params_withlog(Prepared_statement *stmt, String *query) if (query->copy(stmt->query, stmt->query_length, default_charset_info)) DBUG_RETURN(1); - + for (; it < end; ++it, ++client_param) { Item_param *param= *it; @@ -759,10 +759,10 @@ static bool emb_insert_params_withlog(Prepared_statement *stmt, String *query) else { uchar *buff= (uchar*)client_param->buffer; - param->unsigned_flag= client_param->is_unsigned; + param->unsigned_flag= client_param->is_unsigned; param->set_param_func(param, &buff, - client_param->length ? - *client_param->length : + client_param->length ? + *client_param->length : client_param->buffer_length); } } @@ -881,12 +881,12 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt, } /* - Validate INSERT statement: + Validate INSERT statement: SYNOPSIS mysql_test_insert() - stmt prepared statemen handler - tables global/local table list + stmt prepared statemen handler + tables global/local table list RETURN VALUE FALSE success @@ -895,7 +895,7 @@ static bool insert_params_from_vars_with_log(Prepared_statement *stmt, static bool mysql_test_insert(Prepared_statement *stmt, TABLE_LIST *table_list, - List<Item> &fields, + List<Item> &fields, List<List_item> &values_list, List<Item> &update_fields, List<Item> &update_values, @@ -958,7 +958,7 @@ static bool mysql_test_insert(Prepared_statement *stmt, goto error; } if (setup_fields(thd, 0, table_list, *values, 0, 0, 0)) - goto error; + goto error; } } DBUG_RETURN(FALSE); @@ -974,8 +974,8 @@ error: SYNOPSIS mysql_test_update() - stmt prepared statemen handler - tables list of tables queries + stmt prepared statemen handler + tables list of tables queries RETURN VALUE 0 success @@ -991,7 +991,7 @@ static int mysql_test_update(Prepared_statement *stmt, uint table_count= 0; SELECT_LEX *select= &stmt->lex->select_lex; #ifndef NO_EMBEDDED_ACCESS_CHECKS - uint want_privilege; + uint want_privilege; #endif DBUG_ENTER("mysql_test_update"); @@ -1046,7 +1046,7 @@ static int mysql_test_update(Prepared_statement *stmt, #endif if (setup_fields(thd, 0, table_list, stmt->lex->value_list, 0, 0, 0)) goto error; - /* TODO: here we should send types of placeholders to the client. */ + /* TODO: here we should send types of placeholders to the client. */ DBUG_RETURN(0); error: DBUG_RETURN(1); @@ -1058,8 +1058,8 @@ error: SYNOPSIS mysql_test_delete() - stmt prepared statemen handler - tables list of tables queries + stmt prepared statemen handler + tables list of tables queries RETURN VALUE FALSE success @@ -1093,12 +1093,12 @@ error: /* Validate SELECT statement. In case of success, if this query is not EXPLAIN, send column list info - back to client. + back to client. SYNOPSIS mysql_test_select() - stmt prepared statemen handler - tables list of tables queries + stmt prepared statemen handler + tables list of tables queries RETURN VALUE FALSE success @@ -1180,9 +1180,9 @@ error: SYNOPSIS mysql_test_do_fields() - stmt prepared statemen handler - tables list of tables queries - values list of expressions + stmt prepared statemen handler + tables list of tables queries + values list of expressions RETURN VALUE FALSE success @@ -1190,8 +1190,8 @@ error: */ static bool mysql_test_do_fields(Prepared_statement *stmt, - TABLE_LIST *tables, - List<Item> *values) + TABLE_LIST *tables, + List<Item> *values) { THD *thd= stmt->thd; @@ -1210,9 +1210,9 @@ static bool mysql_test_do_fields(Prepared_statement *stmt, SYNOPSIS mysql_test_set_fields() - stmt prepared statemen handler - tables list of tables queries - values list of expressions + stmt prepared statemen handler + tables list of tables queries + values list of expressions RETURN VALUE FALSE success @@ -1323,8 +1323,8 @@ select_like_stmt_test_with_open_n_lock(Prepared_statement *stmt, SYNOPSIS mysql_test_create_table() - stmt prepared statemen handler - tables list of tables queries + stmt prepared statemen handler + tables list of tables queries RETURN VALUE FALSE success @@ -1364,8 +1364,8 @@ static bool mysql_test_create_table(Prepared_statement *stmt) SYNOPSIS mysql_test_multiupdate() - stmt prepared statemen handler - tables list of tables queries + stmt prepared statemen handler + tables list of tables queries converted converted to multi-update from usual update RETURN VALUE @@ -1374,7 +1374,7 @@ static bool mysql_test_create_table(Prepared_statement *stmt) */ static bool mysql_test_multiupdate(Prepared_statement *stmt, - TABLE_LIST *tables, + TABLE_LIST *tables, bool converted) { /* if we switched from normal update, rights are checked */ @@ -1391,8 +1391,8 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt, SYNOPSIS mysql_test_multidelete() - stmt prepared statemen handler - tables list of tables queries + stmt prepared statemen handler + tables list of tables queries RETURN VALUE 0 success @@ -1400,7 +1400,7 @@ static bool mysql_test_multiupdate(Prepared_statement *stmt, */ static bool mysql_test_multidelete(Prepared_statement *stmt, - TABLE_LIST *tables) + TABLE_LIST *tables) { uint fake_counter; @@ -1419,7 +1419,7 @@ static bool mysql_test_multidelete(Prepared_statement *stmt, if (!tables->table) { my_error(ER_VIEW_DELETE_MERGE_VIEW, MYF(0), - tables->view_db.str, tables->view_name.str); + tables->view_db.str, tables->view_name.str); goto error; } return FALSE; @@ -1460,8 +1460,8 @@ static bool mysql_insert_select_prepare_tester(THD *thd) SYNOPSIS mysql_test_insert_select() - stmt prepared statemen handler - tables list of tables of query + stmt prepared statemen handler + tables list of tables of query RETURN VALUE 0 success @@ -1470,7 +1470,7 @@ static bool mysql_insert_select_prepare_tester(THD *thd) */ static int mysql_test_insert_select(Prepared_statement *stmt, - TABLE_LIST *tables) + TABLE_LIST *tables) { int res; LEX *lex= stmt->lex; @@ -1538,9 +1538,9 @@ static bool check_prepared_statement(Prepared_statement *stmt, case SQLCOM_REPLACE: case SQLCOM_INSERT: res= mysql_test_insert(stmt, tables, lex->field_list, - lex->many_values, - select_lex->item_list, lex->value_list, - lex->duplicates); + lex->many_values, + select_lex->item_list, lex->value_list, + lex->duplicates); break; case SQLCOM_UPDATE: @@ -1566,7 +1566,7 @@ static bool check_prepared_statement(Prepared_statement *stmt, case SQLCOM_CREATE_TABLE: res= mysql_test_create_table(stmt); break; - + case SQLCOM_DO: res= mysql_test_do_fields(stmt, tables, lex->insert_list); break; @@ -1661,30 +1661,30 @@ static bool init_param_array(Prepared_statement *stmt) /* Given a query string with parameter markers, create a Prepared Statement from it and send PS info back to the client. - + SYNOPSIS mysql_stmt_prepare() - packet query to be prepared - packet_length query string length, including ignored trailing NULL or + packet query to be prepared + packet_length query string length, including ignored trailing NULL or quote char. name NULL or statement name. For unnamed statements binary PS - protocol is used, for named statements text protocol is + protocol is used, for named statements text protocol is used. RETURN FALSE OK, statement prepared successfully TRUE Error NOTES - This function parses the query and sends the total number of parameters - and resultset metadata information back to client (if any), without - executing the query i.e. without any log/disk writes. This allows the - queries to be re-executed without re-parsing during execute. + This function parses the query and sends the total number of parameters + and resultset metadata information back to client (if any), without + executing the query i.e. without any log/disk writes. This allows the + queries to be re-executed without re-parsing during execute. If parameter markers are found in the query, then store the information - using Item_param along with maintaining a list in lex->param_array, so - that a fast and direct retrieval can be made without going through all + using Item_param along with maintaining a list in lex->param_array, so + that a fast and direct retrieval can be made without going through all field items. - + */ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, @@ -1857,8 +1857,8 @@ void reset_stmt_for_execute(THD *thd, LEX *lex) } /* - TODO: When the new table structure is ready, then have a status bit - to indicate the table is altered, and re-do the setup_* + TODO: When the new table structure is ready, then have a status bit + to indicate the table is altered, and re-do the setup_* and open the tables back. */ /* @@ -1867,8 +1867,8 @@ void reset_stmt_for_execute(THD *thd, LEX *lex) they have their own table list). */ for (TABLE_LIST *tables= lex->query_tables; - tables; - tables= tables->next_global) + tables; + tables= tables->next_global) { /* Reset old pointers to TABLEs: they are not valid since the tables @@ -1899,10 +1899,10 @@ void reset_stmt_for_execute(THD *thd, LEX *lex) /* Clears parameters from data left from previous execution or long data - + SYNOPSIS reset_stmt_params() - stmt prepared statement for which parameters should be reset + stmt prepared statement for which parameters should be reset */ static void reset_stmt_params(Prepared_statement *stmt) @@ -1999,8 +1999,8 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) } #else /* - In embedded library we re-install conversion routines each time - we set params, and also we don't need to parse packet. + In embedded library we re-install conversion routines each time + we set params, and also we don't need to parse packet. So we do it in one function. */ if (stmt->param_count && stmt->set_params_data(stmt, &expanded_query)) @@ -2163,9 +2163,9 @@ static void execute_stmt(THD *thd, Prepared_statement *stmt, SYNOPSIS mysql_stmt_fetch() - thd Thread handler - packet Packet from client (with stmt_id & num_rows) - packet_length Length of packet + thd Thread handler + packet Packet from client (with stmt_id & num_rows) + packet_length Length of packet */ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) @@ -2192,7 +2192,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) if (!(specialflag & SPECIAL_NO_PRIOR)) my_pthread_setprio(pthread_self(), QUERY_PRIOR); - thd->protocol= &thd->protocol_prep; // Switch to binary protocol + thd->protocol= &thd->protocol_prep; // Switch to binary protocol stmt->cursor->fetch(num_rows); thd->protocol= &thd->protocol_simple; // Use normal protocol @@ -2213,7 +2213,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length) SYNOPSIS mysql_stmt_reset() thd Thread handle - packet Packet with stmt id + packet Packet with stmt id DESCRIPTION This function resets statement to the state it was right after prepare. @@ -2240,22 +2240,22 @@ void mysql_stmt_reset(THD *thd, char *packet) stmt->state= Item_arena::PREPARED; - /* - Clear parameters from data which could be set by + /* + Clear parameters from data which could be set by mysql_stmt_send_long_data() call. */ reset_stmt_params(stmt); mysql_reset_thd_for_next_command(thd); send_ok(thd); - + DBUG_VOID_RETURN; } /* Delete a prepared statement from memory. - Note: we don't send any reply to that command. + Note: we don't send any reply to that command. */ void mysql_stmt_free(THD *thd, char *packet) @@ -2280,9 +2280,9 @@ void mysql_stmt_free(THD *thd, char *packet) SYNOPSIS mysql_stmt_get_longdata() - thd Thread handle - pos String to append - packet_length Length of string + thd Thread handle + pos String to append + packet_length Length of string DESCRIPTION Get a part of a long data. @@ -2301,7 +2301,7 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) Prepared_statement *stmt; Item_param *param; char *packet_end= packet + packet_length - 1; - + DBUG_ENTER("mysql_stmt_get_longdata"); #ifndef EMBEDDED_LIBRARY |