Bug12589870 post-merge fixes for Sparc64 and friends

sql/sp_head.cc:
  alignment-safe copy
sql/sql_cache.cc:
  alignment-safe copy
sql/sql_parse.cc:
  alignment-safe copy
This commit is contained in:
Tatjana Azundris Nuernberg 2011-10-19 03:21:31 +01:00
parent 5dc553cd28
commit 8444b6a114
3 changed files with 8 additions and 5 deletions

View File

@ -1044,7 +1044,7 @@ subst_spvars(THD *thd, sp_instr *instr, LEX_STRING *query_str)
{ {
memcpy(pbuf, qbuf.ptr(), qbuf.length()); memcpy(pbuf, qbuf.ptr(), qbuf.length());
pbuf[qbuf.length()]= 0; pbuf[qbuf.length()]= 0;
*(size_t *)(pbuf+qbuf.length()+1)= thd->db_length; memcpy(pbuf+qbuf.length()+1, (char *) &thd->db_length, sizeof(size_t));
} }
else else
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);

View File

@ -1471,8 +1471,9 @@ Query_cache::send_result_to_client(THD *thd, char *sql, uint query_length)
sure the new current database has a name with the same length sure the new current database has a name with the same length
as the previous one. as the previous one.
*/ */
size_t *db_len= (size_t *) (sql + query_length + 1); size_t db_len;
if (thd->db_length != *db_len) memcpy((char *) &db_len, (sql + query_length + 1), sizeof(size_t));
if (thd->db_length != db_len)
{ {
/* /*
We should probably reallocate the buffer in this case, We should probably reallocate the buffer in this case,

View File

@ -492,6 +492,8 @@ static void handle_bootstrap_impl(THD *thd)
query= (char *) thd->memdup_w_gap(buff, length + 1, query= (char *) thd->memdup_w_gap(buff, length + 1,
thd->db_length + 1 + thd->db_length + 1 +
QUERY_CACHE_FLAGS_SIZE); QUERY_CACHE_FLAGS_SIZE);
size_t db_len= 0;
memcpy(query + length + 1, (char *) &db_len, sizeof(size_t));
thd->set_query(query, length); thd->set_query(query, length);
DBUG_PRINT("query",("%-.4096s", thd->query())); DBUG_PRINT("query",("%-.4096s", thd->query()));
#if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER) #if defined(ENABLED_PROFILING) && defined(COMMUNITY_SERVER)
@ -1933,8 +1935,8 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length)
also store this length, in case current database is changed during also store this length, in case current database is changed during
execution. We might need to reallocate the 'query' buffer execution. We might need to reallocate the 'query' buffer
*/ */
size_t *len = (size_t *) (query + packet_length + 1); char *len_pos = (query + packet_length + 1);
*len= thd->db_length; memcpy(len_pos, (char *) &thd->db_length, sizeof(size_t));
thd->set_query(query, packet_length); thd->set_query(query, packet_length);