Coding style notes...
On Tue, Oct 13, 2009 at 04:19:57PM +0000, Georgi Kodinov wrote:
> === modified file 'sql/ha_ndbcluster.cc'
> --- a/sql/ha_ndbcluster.cc 2009-09-23 13:10:23 +0000
> +++ b/sql/ha_ndbcluster.cc 2009-10-13 16:19:50 +0000
> @@ -5967,7 +5967,8 @@ int ha_ndbcluster::rename_table(const ch
> */
> if (!is_old_table_tmpfile)
> ndbcluster_log_schema_op(current_thd, share,
> - current_thd->query, current_thd->query_length,
> + current_thd->query(),
Trailing space here.
> === modified file 'sql/log_event.cc'
> --- a/sql/log_event.cc 2009-09-29 13:08:18 +0000
> +++ b/sql/log_event.cc 2009-10-13 16:19:50 +0000
> @@ -3039,7 +3039,7 @@ int Query_log_event::do_apply_event(Rela
> thd->query_id = next_query_id();
> VOID(pthread_mutex_unlock(&LOCK_thread_count));
> thd->variables.pseudo_thread_id= thread_id; // for temp tables
> - DBUG_PRINT("query",("%s",thd->query));
> + DBUG_PRINT("query",("%s",thd->query()));
Add a space after comma.
> @@ -4489,8 +4489,8 @@ int Load_log_event::do_apply_event(NET*
> new_db.length= db_len;
> new_db.str= (char *) rpl_filter->get_rewrite_db(db, &new_db.length);
> thd->set_db(new_db.str, new_db.length);
> - DBUG_ASSERT(thd->query == 0);
> - thd->query_length= 0; // Should not be needed
> + DBUG_ASSERT(thd->query() == 0);
> + thd->set_query_inner (NULL, 0); // Should not be needed
No space between set_query_inner and "(".
> === modified file 'sql/slave.cc'
> --- a/sql/slave.cc 2009-09-30 22:25:06 +0000
> +++ b/sql/slave.cc 2009-10-13 16:19:50 +0000
> @@ -1288,7 +1288,7 @@ static int create_table_from_dump(THD* t
> thd->db = (char*)db;
> DBUG_ASSERT(thd->db != 0);
> thd->db_length= strlen(thd->db);
> - mysql_parse(thd, thd->query, packet_len, &found_semicolon); // run create
> table
> + mysql_parse(thd, thd->query(), packet_len, &found_semicolon); // run create
> table
Too long line above.
> === modified file 'sql/sp_head.cc'
> --- a/sql/sp_head.cc 2009-07-29 20:07:08 +0000
> +++ b/sql/sp_head.cc 2009-10-13 16:19:50 +0000
> @@ -2840,10 +2840,11 @@ sp_instr_stmt::execute(THD *thd, uint *n
> queries with SP vars can't be cached)
> */
> if (unlikely((thd->options & OPTION_LOG_OFF)==0))
> - general_log_write(thd, COM_QUERY, thd->query, thd->query_length);
> + general_log_write(thd, COM_QUERY, thd->query(), thd->query_length());
>
> if (query_cache_send_result_to_client(thd,
> - thd->query, thd->query_length) <= 0)
> + thd->query(),
Wrong indentation + tabs + trailing space.
> + thd->query_length()) <= 0)
> {
> res= m_lex_keeper.reset_lex_and_exec_core(thd, nextp, FALSE, this);
>
>
> === modified file 'sql/sql_cache.cc'
> --- a/sql/sql_cache.cc 2009-09-23 13:21:29 +0000
> +++ b/sql/sql_cache.cc 2009-10-13 16:19:50 +0000
> @@ -1119,8 +1119,8 @@ void Query_cache::store_query(THD *thd,
> DBUG_VOID_RETURN;
> uint8 tables_type= 0;
>
> - if ((local_tables= is_cacheable(thd, thd->query_length,
> - thd->query, thd->lex, tables_used,
> + if ((local_tables= is_cacheable(thd, thd->query_length(),
> + thd->query(), thd->lex, tables_used,
Wrong indentation + tabs.
> @@ -1210,7 +1210,7 @@ def_week_frmt: %lu, in_trans: %d, autoco
> /* Key is query + database + flag */
> if (thd->db_length)
> {
> - memcpy(thd->query+thd->query_length+1, thd->db, thd->db_length);
> + memcpy(thd->query()+thd->query_length()+1, thd->db,
> thd->db_length);
Put spaces both before and after binary comparison operators ('>', '==',
'>=', etc.), binary arithmetic operators ('+' etc.), and binary Boolean
operators ('||' etc.).
> @@ -1218,24 +1218,24 @@ def_week_frmt: %lu, in_trans: %d, autoco
> {
> DBUG_PRINT("qcache", ("No active database"));
> }
> - tot_length= thd->query_length + thd->db_length + 1 +
> + tot_length= thd->query_length() + thd->db_length + 1 +
> QUERY_CACHE_FLAGS_SIZE;
> /*
> We should only copy structure (don't use it location directly)
> because of alignment issue
> */
> - memcpy((void *)(thd->query + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
> + memcpy((void *)(thd->query() + (tot_length - QUERY_CACHE_FLAGS_SIZE)),
We write casts as (void*) (...).
> &flags, QUERY_CACHE_FLAGS_SIZE);
>
> /* Check if another thread is processing the same query? */
> Query_cache_block *competitor = (Query_cache_block *)
> - hash_search(&queries, (uchar*) thd->query, tot_length);
> + hash_search(&queries, (uchar*) thd->query(), tot_length);
Like here...
> === modified file 'sql/sql_db.cc'
> --- a/sql/sql_db.cc 2009-09-23 13:21:29 +0000
> +++ b/sql/sql_db.cc 2009-10-13 16:19:50 +0000
> @@ -703,7 +703,7 @@ not_silent:
> char *query;
> uint query_length;
>
> - if (!thd->query) // Only in replication
> + if (!thd->query()) // Only in replication
Tabs.
> @@ -711,8 +711,8 @@ not_silent:
> }
> else
> {
> - query= thd->query;
> - query_length= thd->query_length;
> + query= thd->query();
Tabs.
> @@ -957,8 +957,8 @@ bool mysql_rm_db(THD *thd,char *db,bool
> }
> else
> {
> - query =thd->query;
> - query_length= thd->query_length;
> + query =thd->query();
query= ...
> === modified file 'sql/sql_insert.cc'
> --- a/sql/sql_insert.cc 2009-09-10 07:40:57 +0000
> +++ b/sql/sql_insert.cc 2009-10-13 16:19:50 +0000
> @@ -894,7 +894,7 @@ bool mysql_insert(THD *thd,TABLE_LIST *t
> */
> DBUG_ASSERT(thd->killed != THD::KILL_BAD_DATA || error > 0);
> if (thd->binlog_query(THD::ROW_QUERY_TYPE,
> - thd->query, thd->query_length,
> + thd->query(), thd->query_length(),
Tabs.
> @@ -3320,7 +3320,8 @@ void select_insert::abort() {
> if (mysql_bin_log.is_open())
> {
> int errcode= query_error_code(thd, thd->killed == THD::NOT_KILLED);
> - thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query,
> thd->query_length,
> + thd->binlog_query(THD::ROW_QUERY_TYPE, thd->query(),
Trailing space.
> === modified file 'sql/sql_load.cc'
> --- a/sql/sql_load.cc 2009-09-28 12:41:10 +0000
> +++ b/sql/sql_load.cc 2009-10-13 16:19:50 +0000
> @@ -654,13 +654,12 @@ static bool write_execute_load_query_log
> strcpy(end, p);
> end += pl;
>
> - thd->query_length= end - load_data_query;
> - thd->query= load_data_query;
> + thd->set_query_inner (load_data_query, end - load_data_query);
No space between set_query_inner and "(".
>
> Execute_load_query_log_event
> - e(thd, thd->query, thd->query_length,
> - (uint) ((char*)fname_start - (char*)thd->query - 1),
> - (uint) ((char*)fname_end - (char*)thd->query),
> + e(thd, thd->query(), thd->query_length(),
> + (uint) ((char*)fname_start - (char*)thd->query() - 1),
> + (uint) ((char*)fname_end - (char*)thd->query()),
Spaces after "(char*)" cast.
> === modified file 'sql/sql_parse.cc'
> --- a/sql/sql_parse.cc 2009-10-07 15:03:42 +0000
> +++ b/sql/sql_parse.cc 2009-10-13 16:19:50 +0000
> @@ -477,10 +477,10 @@ static void handle_bootstrap_impl(THD *t
> thd->db_length + 1 +
> QUERY_CACHE_FLAGS_SIZE);
> thd->set_query(query, length);
> - DBUG_PRINT("query",("%-.4096s",thd->query));
> + DBUG_PRINT("query",("%-.4096s",thd->query()));
Space after comma.
> @@ -1208,20 +1208,20 @@ bool dispatch_command(enum enum_server_c
> {
> if (alloc_query(thd, packet, packet_length))
> break; // fatal error is set
> - char *packet_end= thd->query + thd->query_length;
> + char *packet_end= thd->query() + thd->query_length();
> /* 'b' stands for 'buffer' parameter', special for 'my_snprintf' */
> const char* end_of_stmt= NULL;
>
> - general_log_write(thd, command, thd->query, thd->query_length);
> - DBUG_PRINT("query",("%-.4096s",thd->query));
> + general_log_write(thd, command, thd->query(), thd->query_length());
> + DBUG_PRINT("query",("%-.4096s",thd->query()));
Space after comma.
> @@ -5950,9 +5951,9 @@ void mysql_parse(THD *thd, const char *i
> PROCESSLIST.
> Note that we don't need LOCK_thread_count to modify query_length.
> */
> - if (*found_semicolon &&
> - (thd->query_length= (ulong)(*found_semicolon - thd->query)))
> - thd->query_length--;
> + if (*found_semicolon && (ulong)(*found_semicolon -
> thd->query()))
Space after cast.
> + thd->set_query_inner (thd->query(),
No space between set_query_inner and "(".
> + (uint32)(*found_semicolon - thd->query() -
> 1));
Space after cast.
> === modified file 'sql/sql_prepare.cc'
> --- a/sql/sql_prepare.cc 2009-08-28 16:21:54 +0000
> +++ b/sql/sql_prepare.cc 2009-10-13 16:19:50 +0000
> @@ -3547,8 +3547,7 @@ bool Prepared_statement::execute(String
> to point at it even after we restore from backup. This is ok, as
> expanded query was allocated in thd->mem_root.
> */
> - stmt_backup.query= thd->query;
> - stmt_backup.query_length= thd->query_length;
> + stmt_backup.set_query_inner (thd->query(), thd->query_length());
No space between set_query_inner and "(".
> === modified file 'sql/sql_show.cc'
> --- a/sql/sql_show.cc 2009-09-30 07:31:20 +0000
> +++ b/sql/sql_show.cc 2009-10-13 16:19:50 +0000
> @@ -1864,10 +1864,10 @@ void mysqld_list_processes(THD *thd,cons
> thd_info->query=0;
> /* Lock THD mutex that protects its data when looking at it. */
> pthread_mutex_lock(&tmp->LOCK_thd_data);
> - if (tmp->query)
> + if (tmp->query())
> {
> - uint length= min(max_query_length, tmp->query_length);
> - thd_info->query=(char*) thd->strmake(tmp->query,length);
> + uint length= min(max_query_length, tmp->query_length());
> + thd_info->query=(char*) thd->strmake(tmp->query(),length);
Space after "=".
Regards,
Sergey
--
Sergey Vojtovich <svoj@stripped>
MySQL AB, Software Engineer
Izhevsk, Russia, www.mysql.com