Commit 1de4fff5 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Update of query cache code.

Changed some sql_alloc() -> thd->alloc()
Removed a lot of compiler warnings on Linux Alpha (64 bit)
Fixed some core dumps on 64 bit systems (wrong type for packet_len)
parent 1d26537d
...@@ -18100,6 +18100,9 @@ differ somewhat: ...@@ -18100,6 +18100,9 @@ differ somewhat:
| protocol_version | 10 | | protocol_version | 10 |
| record_buffer | 131072 | | record_buffer | 131072 |
| query_buffer_size | 0 | | query_buffer_size | 0 |
| query_cache_limit | 1048576 |
| query_cache_size | 16768060 |
| query_cache_startup_type | 1 |
| safe_show_database | OFF | | safe_show_database | OFF |
| server_id | 0 | | server_id | 0 |
| skip_locking | ON | | skip_locking | ON |
...@@ -18497,6 +18500,18 @@ buffer to avoid a disk seeks. If not set, then it's set to the value of ...@@ -18497,6 +18500,18 @@ buffer to avoid a disk seeks. If not set, then it's set to the value of
The initial allocation of the query buffer. If most of your queries are The initial allocation of the query buffer. If most of your queries are
long (like when inserting blobs), you should increase this! long (like when inserting blobs), you should increase this!
@item @code{query_cache_limit}
Don't cache results that are bigger than this. (Default 1M).
@item @code{query_cache_size}
The memory allocated to store results from old queries. If this is zero
the query cache is disabled.
@item @code{query_cache_startup_type}
This may have be set to 0 (cache results but don't retrieve results from
cache), 1 (cache results by defaults) or 2 (only cache @code{SELECT}'s marked
with @code{SQL_CACHE}).
@item @code{safe_show_databases} @item @code{safe_show_databases}
Don't show databases for which the user doesn't have any database or Don't show databases for which the user doesn't have any database or
table privileges. This can improve security if you're concerned about table privileges. This can improve security if you're concerned about
...@@ -25730,6 +25745,17 @@ flag again, the @code{SQL_MAX_JOIN_SIZE} variable will be ignored. ...@@ -25730,6 +25745,17 @@ flag again, the @code{SQL_MAX_JOIN_SIZE} variable will be ignored.
You can set a default value for this variable by starting @code{mysqld} with You can set a default value for this variable by starting @code{mysqld} with
@code{-O max_join_size=#}. @code{-O max_join_size=#}.
@item SQL_QUERY_CACHE_TYPE = [OFF | ON | DEMAND]
@item SQL_QUERY_CACHE_TYPE = [0 | 1 | 2]
The numbers are standing for the correspoding verbose option.
@multitable @columnfractions .3 .7
@item 0 or OFF @tab Cache @code{SELECT} results, but don't retrieve results from cache.
@item 1 or ON @tab Cache all @code{SELECT}'s that are not marked with @code{SQL_NO_CACHE}.
@item 2 or DEMAND @tab Cache only @code{SELECT SQL_CACHE}) queries.
@end multitable
@item SQL_SAFE_UPDATES = 0 | 1 @item SQL_SAFE_UPDATES = 0 | 1
If set to @code{1}, MySQL will abort if an @code{UPDATE} or If set to @code{1}, MySQL will abort if an @code{UPDATE} or
@code{DELETE} is attempted that doesn't use a key or @code{LIMIT} in the @code{DELETE} is attempted that doesn't use a key or @code{LIMIT} in the
...@@ -31085,7 +31111,7 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND(); ...@@ -31085,7 +31111,7 @@ mysql> SELECT id,FLOOR(value/100) FROM tbl_name ORDER BY RAND();
@c help SELECT @c help SELECT
@example @example
SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT] SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
[HIGH_PRIORITY] [SQL_CACHE | SQL_NO_CACHE] [HIGH_PRIORITY]
[DISTINCT | DISTINCTROW | ALL] [DISTINCT | DISTINCTROW | ALL]
select_expression,... select_expression,...
[INTO @{OUTFILE | DUMPFILE@} 'file_name' export_options] [INTO @{OUTFILE | DUMPFILE@} 'file_name' export_options]
...@@ -31213,9 +31239,8 @@ mysql> select user,max(salary) AS sum from users ...@@ -31213,9 +31239,8 @@ mysql> select user,max(salary) AS sum from users
@end example @end example
@item @item
@code{SQL_SMALL_RESULT}, @code{SQL_BIG_RESULT}, @code{SQL_BUFFER_RESULT}, All options beginning with @code{SQL_}, @code{STRAIGHT_JOIN}, and
@code{STRAIGHT_JOIN}, and @code{HIGH_PRIORITY} are MySQL extensions @code{HIGH_PRIORITY} are MySQL extensions to ANSI SQL.
to ANSI SQL92.
@item @item
@code{HIGH_PRIORITY} will give the @code{SELECT} higher priority than @code{HIGH_PRIORITY} will give the @code{SELECT} higher priority than
...@@ -31243,6 +31268,14 @@ result set will be small. In this case, MySQL will use fast ...@@ -31243,6 +31268,14 @@ result set will be small. In this case, MySQL will use fast
temporary tables to store the resulting table instead of using sorting. In temporary tables to store the resulting table instead of using sorting. In
MySQL Version 3.23 this shouldn't normally be needed. MySQL Version 3.23 this shouldn't normally be needed.
@item
@code{SQL_CACHE} tells MySQL to store the query result in the query cache
even if you are using @code{SQL_QUERY_CACHE_METHOD} 2 (= @code{DEMAND}).
@item
@code{SQL_NO_CACHE} tells MySL to not store the query result in the
query cache.
@item @item
@cindex @code{GROUP BY}, extensions to ANSI SQL @cindex @code{GROUP BY}, extensions to ANSI SQL
If you use @code{GROUP BY}, the output rows will be sorted according to the If you use @code{GROUP BY}, the output rows will be sorted according to the
...@@ -46164,6 +46197,11 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -46164,6 +46197,11 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet @itemize @bullet
@item @item
A new query cache to cache results from identical @code{SELECT} queries.
@item
Fixed core dump bug on 64 bit machines when it got a wrong communication
packet.
@item
@code{MATCH ... AGAINST(... IN BOOLEAN MODE)} can now work @code{MATCH ... AGAINST(... IN BOOLEAN MODE)} can now work
without @code{FULLTEXT} index. without @code{FULLTEXT} index.
@item @item
...@@ -54,6 +54,7 @@ gptr hash_next(HASH *info,const byte *key,uint length); ...@@ -54,6 +54,7 @@ gptr hash_next(HASH *info,const byte *key,uint length);
my_bool hash_insert(HASH *info,const byte *data); my_bool hash_insert(HASH *info,const byte *data);
my_bool hash_delete(HASH *hash,byte *record); my_bool hash_delete(HASH *hash,byte *record);
my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length); my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length);
void hash_replace(HASH *hash, uint idx, byte *new_row);
my_bool hash_check(HASH *hash); /* Only in debug library */ my_bool hash_check(HASH *hash); /* Only in debug library */
#define hash_clear(H) bzero((char*) (H),sizeof(*(H))) #define hash_clear(H) bzero((char*) (H),sizeof(*(H)))
......
...@@ -192,7 +192,7 @@ typedef struct st_columndef /* column information */ ...@@ -192,7 +192,7 @@ typedef struct st_columndef /* column information */
} MI_COLUMNDEF; } MI_COLUMNDEF;
/* invalidator function reference for Query Cache */ /* invalidator function reference for Query Cache */
typedef void (* invalidator_by_filename) (char * filename); typedef void (* invalidator_by_filename)(const char * filename);
extern my_string myisam_log_filename; /* Name of logfile */ extern my_string myisam_log_filename; /* Name of logfile */
extern uint myisam_block_size; extern uint myisam_block_size;
......
...@@ -94,6 +94,7 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a ...@@ -94,6 +94,7 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
extern ulong bytes_sent, bytes_received; extern ulong bytes_sent, bytes_received;
extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received; extern pthread_mutex_t LOCK_bytes_sent , LOCK_bytes_received;
extern void query_cache_insert(NET *net, const char *packet, ulong length);
#else #else
#undef statistic_add #undef statistic_add
#define statistic_add(A,B,C) #define statistic_add(A,B,C)
...@@ -108,7 +109,7 @@ static int net_write_buff(NET *net,const char *packet,ulong len); ...@@ -108,7 +109,7 @@ static int net_write_buff(NET *net,const char *packet,ulong len);
int my_net_init(NET *net, Vio* vio) int my_net_init(NET *net, Vio* vio)
{ {
if (!(net->buff=(uchar*) my_malloc(net_buffer_length+ if (!(net->buff=(uchar*) my_malloc((uint32) net_buffer_length+
NET_HEADER_SIZE + COMP_HEADER_SIZE, NET_HEADER_SIZE + COMP_HEADER_SIZE,
MYF(MY_WME)))) MYF(MY_WME))))
return 1; return 1;
...@@ -125,6 +126,7 @@ int my_net_init(NET *net, Vio* vio) ...@@ -125,6 +126,7 @@ int my_net_init(NET *net, Vio* vio)
net->compress=0; net->reading_or_writing=0; net->compress=0; net->reading_or_writing=0;
net->where_b = net->remain_in_buf=0; net->where_b = net->remain_in_buf=0;
net->last_errno=0; net->last_errno=0;
net->query_cache_query=0;
if (vio != 0) /* If real connection */ if (vio != 0) /* If real connection */
{ {
...@@ -160,7 +162,7 @@ static my_bool net_realloc(NET *net, ulong length) ...@@ -160,7 +162,7 @@ static my_bool net_realloc(NET *net, ulong length)
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1); pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
/* We must allocate some extra bytes for the end 0 and to be able to /* We must allocate some extra bytes for the end 0 and to be able to
read big compressed blocks */ read big compressed blocks */
if (!(buff=(uchar*) my_realloc((char*) net->buff, pkt_length + if (!(buff=(uchar*) my_realloc((char*) net->buff, (uint32) pkt_length +
NET_HEADER_SIZE + COMP_HEADER_SIZE, NET_HEADER_SIZE + COMP_HEADER_SIZE,
MYF(MY_WME)))) MYF(MY_WME))))
{ {
...@@ -187,7 +189,7 @@ void net_clear(NET *net) ...@@ -187,7 +189,7 @@ void net_clear(NET *net)
if (!vio_is_blocking(net->vio)) /* Safety if SSL */ if (!vio_is_blocking(net->vio)) /* Safety if SSL */
{ {
while ( (count = vio_read(net->vio, (char*) (net->buff), while ( (count = vio_read(net->vio, (char*) (net->buff),
net->max_packet)) > 0) (uint32) net->max_packet)) > 0)
DBUG_PRINT("info",("skipped %d bytes from file: %s", DBUG_PRINT("info",("skipped %d bytes from file: %s",
count,vio_description(net->vio))); count,vio_description(net->vio)));
if (is_blocking) if (is_blocking)
...@@ -241,7 +243,7 @@ my_net_write(NET *net,const char *packet,ulong len) ...@@ -241,7 +243,7 @@ my_net_write(NET *net,const char *packet,ulong len)
{ {
const ulong z_size = MAX_THREE_BYTES; const ulong z_size = MAX_THREE_BYTES;
int3store(buff, z_size); int3store(buff, z_size);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) || if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) ||
net_write_buff(net, packet, z_size)) net_write_buff(net, packet, z_size))
return 1; return 1;
...@@ -250,7 +252,7 @@ my_net_write(NET *net,const char *packet,ulong len) ...@@ -250,7 +252,7 @@ my_net_write(NET *net,const char *packet,ulong len)
} }
/* Write last packet */ /* Write last packet */
int3store(buff,len); int3store(buff,len);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE)) if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
return 1; return 1;
return net_write_buff(net,packet,len); return net_write_buff(net,packet,len);
...@@ -280,7 +282,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) ...@@ -280,7 +282,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
do do
{ {
int3store(buff, MAX_THREE_BYTES); int3store(buff, MAX_THREE_BYTES);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff, header_size) || if (net_write_buff(net,(char*) buff, header_size) ||
net_write_buff(net,packet,len)) net_write_buff(net,packet,len))
return 1; return 1;
...@@ -292,7 +294,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) ...@@ -292,7 +294,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
len=length; /* Data left to be written */ len=length; /* Data left to be written */
} }
int3store(buff,length); int3store(buff,length);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
return test(net_write_buff(net,(char*) buff,header_size) || return test(net_write_buff(net,(char*) buff,header_size) ||
net_write_buff(net,packet,len) || net_flush(net)); net_write_buff(net,packet,len) || net_flush(net));
} }
...@@ -341,6 +343,10 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -341,6 +343,10 @@ net_real_write(NET *net,const char *packet,ulong len)
my_bool net_blocking = vio_is_blocking(net->vio); my_bool net_blocking = vio_is_blocking(net->vio);
DBUG_ENTER("net_real_write"); DBUG_ENTER("net_real_write");
#ifdef MYSQL_SERVER
query_cache_insert(net, packet, len);
#endif
if (net->error == 2) if (net->error == 2)
DBUG_RETURN(-1); /* socket can't be used */ DBUG_RETURN(-1); /* socket can't be used */
...@@ -351,8 +357,8 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -351,8 +357,8 @@ net_real_write(NET *net,const char *packet,ulong len)
ulong complen; ulong complen;
uchar *b; uchar *b;
uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE; uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE;
if (!(b=(uchar*) my_malloc(len + NET_HEADER_SIZE + COMP_HEADER_SIZE, if (!(b=(uchar*) my_malloc((uint32) len + NET_HEADER_SIZE +
MYF(MY_WME)))) COMP_HEADER_SIZE, MYF(MY_WME))))
{ {
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
net->last_errno=ER_OUT_OF_RESOURCES; net->last_errno=ER_OUT_OF_RESOURCES;
...@@ -389,7 +395,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -389,7 +395,7 @@ net_real_write(NET *net,const char *packet,ulong len)
pos=(char*) packet; end=pos+len; pos=(char*) packet; end=pos+len;
while (pos != end) while (pos != end)
{ {
if ((long) (length=vio_write(net->vio,pos,(ulong) (end-pos))) <= 0) if ((long) (length=vio_write(net->vio,pos,(uint32) (end-pos))) <= 0)
{ {
my_bool interrupted = vio_should_retry(net->vio); my_bool interrupted = vio_should_retry(net->vio);
#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) #if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
...@@ -473,7 +479,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -473,7 +479,7 @@ net_real_write(NET *net,const char *packet,ulong len)
big packet big packet
*/ */
static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed)
{ {
ALARM alarm_buff; ALARM alarm_buff;
uint retry_count=0; uint retry_count=0;
...@@ -496,7 +502,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) ...@@ -496,7 +502,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
} }
return; return;
} }
remain -= length; remain -= (uint32) length;
statistic_add(bytes_received,length,&LOCK_bytes_received); statistic_add(bytes_received,length,&LOCK_bytes_received);
} }
} }
...@@ -521,7 +527,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -521,7 +527,7 @@ my_real_read(NET *net, ulong *complen)
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
my_bool net_blocking=vio_is_blocking(net->vio); my_bool net_blocking=vio_is_blocking(net->vio);
ulong remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE : uint32 remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE :
NET_HEADER_SIZE); NET_HEADER_SIZE);
*complen = 0; *complen = 0;
...@@ -599,7 +605,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -599,7 +605,7 @@ my_real_read(NET *net, ulong *complen)
continue; continue;
} }
#endif #endif
DBUG_PRINT("error",("Couldn't read packet: remain: %d errno: %d length: %d alarmed: %d", remain,vio_errno(net->vio),length,alarmed)); DBUG_PRINT("error",("Couldn't read packet: remain: %lu errno: %d length: %ld alarmed: %d", remain,vio_errno(net->vio),length,alarmed));
len= packet_error; len= packet_error;
net->error=2; /* Close socket */ net->error=2; /* Close socket */
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
...@@ -608,7 +614,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -608,7 +614,7 @@ my_real_read(NET *net, ulong *complen)
#endif #endif
goto end; goto end;
} }
remain -= (ulong) length; remain -= (uint32) length;
pos+= (ulong) length; pos+= (ulong) length;
statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received); statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received);
} }
...@@ -655,14 +661,14 @@ my_real_read(NET *net, ulong *complen) ...@@ -655,14 +661,14 @@ my_real_read(NET *net, ulong *complen)
{ {
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
if (i == 1) if (i == 1)
my_net_skip_rest(net, len, &alarmed); my_net_skip_rest(net, (uint32) len, &alarmed);
#endif #endif
len= packet_error; /* Return error */ len= packet_error; /* Return error */
goto end; goto end;
} }
} }
pos=net->buff + net->where_b; pos=net->buff + net->where_b;
remain = len; remain = (uint32) len;
} }
} }
......
...@@ -149,6 +149,12 @@ int mi_write(MI_INFO *info, byte *record) ...@@ -149,6 +149,12 @@ int mi_write(MI_INFO *info, byte *record)
info->lastpos=filepos; info->lastpos=filepos;
myisam_log_record(MI_LOG_WRITE,info,record,filepos,0); myisam_log_record(MI_LOG_WRITE,info,record,filepos,0);
VOID(_mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE)); VOID(_mi_writeinfo(info, WRITEINFO_UPDATE_KEYFILE));
if (info->invalidator != 0)
{
DBUG_PRINT("info", ("invalidator... '%s' (update)", info->filename));
(*info->invalidator)(info->filename);
info->invalidator=0;
}
allow_break(); /* Allow SIGHUP & SIGINT */ allow_break(); /* Allow SIGHUP & SIGINT */
DBUG_RETURN(0); DBUG_RETURN(0);
......
...@@ -50,9 +50,10 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function) ...@@ -50,9 +50,10 @@ int myrg_extra(MYRG_INFO *info,enum ha_extra_function function)
void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv) void myrg_extrafunc(MYRG_INFO *info, invalidator_by_filename inv)
{ {
MYRG_TABLE *file; MYRG_TABLE *file;
DBUG_ENTER("myrg_extrafunc"); DBUG_ENTER("myrg_extrafunc");
for (file=info->open_tables ; file != info->end_table ; file++) for (file=info->open_tables ; file != info->end_table ; file++)
file->table->s->invalidator = inv; file->table->s->invalidator = inv;
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
...@@ -583,6 +583,7 @@ byte *hash_element(HASH *hash,uint idx) ...@@ -583,6 +583,7 @@ byte *hash_element(HASH *hash,uint idx)
void hash_replace(HASH *hash, uint idx, byte *new_row) void hash_replace(HASH *hash, uint idx, byte *new_row)
{ {
if (idx != NO_RECORD) /* Safety */
dynamic_element(&hash->array,idx,HASH_LINK*)->data=new_row; dynamic_element(&hash->array,idx,HASH_LINK*)->data=new_row;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -130,7 +130,7 @@ int ha_myisam::net_read_dump(NET* net) ...@@ -130,7 +130,7 @@ int ha_myisam::net_read_dump(NET* net)
my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME)); my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME));
for(;;) for(;;)
{ {
uint packet_len = my_net_read(net); ulong packet_len = my_net_read(net);
if (!packet_len) if (!packet_len)
break ; // end of file break ; // end of file
if (packet_len == packet_error) if (packet_len == packet_error)
...@@ -139,7 +139,7 @@ int ha_myisam::net_read_dump(NET* net) ...@@ -139,7 +139,7 @@ int ha_myisam::net_read_dump(NET* net)
error= -1; error= -1;
goto err; goto err;
} }
if (my_write(data_fd, (byte*)net->read_pos, packet_len, if (my_write(data_fd, (byte*)net->read_pos, (uint) packet_len,
MYF(MY_WME|MY_FNABP))) MYF(MY_WME|MY_FNABP)))
{ {
error = errno; error = errno;
......
...@@ -206,14 +206,14 @@ public: ...@@ -206,14 +206,14 @@ public:
Item_real(const char *str_arg,uint length) :value(atof(str_arg)) Item_real(const char *str_arg,uint length) :value(atof(str_arg))
{ {
name=(char*) str_arg; name=(char*) str_arg;
decimals=nr_of_decimals(str_arg); decimals=(uint8) nr_of_decimals(str_arg);
max_length=length; max_length=length;
} }
Item_real(const char *str,double val_arg,uint decimal_par,uint length) Item_real(const char *str,double val_arg,uint decimal_par,uint length)
:value(val_arg) :value(val_arg)
{ {
name=(char*) str; name=(char*) str;
decimals=decimal_par; decimals=(uint8) decimal_par;
max_length=length; max_length=length;
} }
Item_real(double value_par) :value(value_par) {} Item_real(double value_par) :value(value_par) {}
......
This diff is collapsed.
This diff is collapsed.
...@@ -50,14 +50,14 @@ extern "C" { ...@@ -50,14 +50,14 @@ extern "C" {
int _my_b_net_read(register IO_CACHE *info, byte *Buffer, int _my_b_net_read(register IO_CACHE *info, byte *Buffer,
uint Count __attribute__((unused))) uint Count __attribute__((unused)))
{ {
int read_length; ulong read_length;
NET *net= &(current_thd)->net; NET *net= &(current_thd)->net;
DBUG_ENTER("_my_b_net_read"); DBUG_ENTER("_my_b_net_read");
if (!info->end_of_file) if (!info->end_of_file)
DBUG_RETURN(1); /* because my_b_get (no _) takes 1 byte at a time */ DBUG_RETURN(1); /* because my_b_get (no _) takes 1 byte at a time */
read_length=my_net_read(net); read_length=my_net_read(net);
if (read_length == (int) packet_error) if (read_length == packet_error)
{ {
info->error= -1; info->error= -1;
DBUG_RETURN(1); DBUG_RETURN(1);
......
...@@ -332,7 +332,7 @@ int mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &list,COND *conds, ...@@ -332,7 +332,7 @@ int mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &list,COND *conds,
ORDER *order, ORDER *group,Item *having,ORDER *proc_param, ORDER *order, ORDER *group,Item *having,ORDER *proc_param,
ulong select_type,select_result *result); ulong select_type,select_result *result);
int mysql_union(THD *thd,LEX *lex,select_result *result); int mysql_union(THD *thd,LEX *lex,select_result *result);
Field *create_tmp_field(TABLE *table,Item *item, Item::Type type, Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item_result_field ***copy_func, Field **from_field, Item_result_field ***copy_func, Field **from_field,
bool group,bool modify_item); bool group,bool modify_item);
int mysql_create_table(THD *thd,const char *db, const char *table_name, int mysql_create_table(THD *thd,const char *db, const char *table_name,
......
...@@ -3091,8 +3091,8 @@ struct show_var_st init_vars[]= { ...@@ -3091,8 +3091,8 @@ struct show_var_st init_vars[]= {
{"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG}, {"record_rnd_buffer", (char*) &record_rnd_cache_size, SHOW_LONG},
{"rpl_recovery_rank", (char*) &rpl_recovery_rank, SHOW_LONG}, {"rpl_recovery_rank", (char*) &rpl_recovery_rank, SHOW_LONG},
{"query_buffer_size", (char*) &query_buff_size, SHOW_LONG}, {"query_buffer_size", (char*) &query_buff_size, SHOW_LONG},
{"query_cache_limit", (char*) &query_cache_limit, SHOW_LONG}, {"query_cache_limit", (char*) &query_cache.query_cache_limit, SHOW_LONG},
{"query_cache_size", (char*) &query_cache_size, SHOW_LONG}, {"query_cache_size", (char*) &query_cache.query_cache_size, SHOW_LONG},
{"query_cache_startup_type",(char*) &query_cache_startup_type, SHOW_LONG}, {"query_cache_startup_type",(char*) &query_cache_startup_type, SHOW_LONG},
{"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL}, {"safe_show_database", (char*) &opt_safe_show_db, SHOW_BOOL},
{"server_id", (char*) &server_id, SHOW_LONG}, {"server_id", (char*) &server_id, SHOW_LONG},
...@@ -3157,11 +3157,11 @@ struct show_var_st status_vars[]= { ...@@ -3157,11 +3157,11 @@ struct show_var_st status_vars[]= {
{"Open_streams", (char*) &my_stream_opened, SHOW_INT_CONST}, {"Open_streams", (char*) &my_stream_opened, SHOW_INT_CONST},
{"Opened_tables", (char*) &opened_tables, SHOW_LONG}, {"Opened_tables", (char*) &opened_tables, SHOW_LONG},
{"Questions", (char*) 0, SHOW_QUESTION}, {"Questions", (char*) 0, SHOW_QUESTION},
{"Qcache_queries", (char*) &query_cache.queries_in_cache, {"Qcache_queries_in_cache", (char*) &query_cache.queries_in_cache,
SHOW_LONG}, SHOW_LONG},
{"Qcache_inserts", (char*) &query_cache.inserts, SHOW_LONG}, {"Qcache_inserts", (char*) &query_cache.inserts, SHOW_LONG},
{"Qcache_hits", (char*) &query_cache.hits, SHOW_LONG}, {"Qcache_hits", (char*) &query_cache.hits, SHOW_LONG},
{"Qcache_refused", (char*) &query_cache.refused, SHOW_LONG}, {"Qcache_not_cached", (char*) &query_cache.refused, SHOW_LONG},
{"Qcache_free_memory", (char*) &query_cache.free_memory,SHOW_LONG}, {"Qcache_free_memory", (char*) &query_cache.free_memory,SHOW_LONG},
{"Rpl_status", (char*) 0, SHOW_RPL_STATUS}, {"Rpl_status", (char*) 0, SHOW_RPL_STATUS},
{"Select_full_join", (char*) &select_full_join_count, SHOW_LONG}, {"Select_full_join", (char*) &select_full_join_count, SHOW_LONG},
...@@ -3726,12 +3726,11 @@ static void get_options(int argc,char **argv) ...@@ -3726,12 +3726,11 @@ static void get_options(int argc,char **argv)
opt_slow_log=1; opt_slow_log=1;
opt_slow_logname=optarg; opt_slow_logname=optarg;
break; break;
case (int)OPT_SKIP_SLAVE_START: case (int) OPT_SKIP_SLAVE_START:
opt_skip_slave_start = 1; opt_skip_slave_start = 1;
break; break;
case (int) OPT_SKIP_NEW: case (int) OPT_SKIP_NEW:
opt_specialflag|= SPECIAL_NO_NEW_FUNC; opt_specialflag|= SPECIAL_NO_NEW_FUNC;
default_table_type=DB_TYPE_ISAM;
myisam_delay_key_write=0; myisam_delay_key_write=0;
myisam_concurrent_insert=0; myisam_concurrent_insert=0;
myisam_recover_options= HA_RECOVER_NONE; myisam_recover_options= HA_RECOVER_NONE;
...@@ -3739,6 +3738,7 @@ static void get_options(int argc,char **argv) ...@@ -3739,6 +3738,7 @@ static void get_options(int argc,char **argv)
my_use_symdir=0; my_use_symdir=0;
have_symlink=SHOW_OPTION_DISABLED; have_symlink=SHOW_OPTION_DISABLED;
ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED; ha_open_options&= ~HA_OPEN_ABORT_IF_CRASHED;
query_cache_size=0;
break; break;
case (int) OPT_SAFE: case (int) OPT_SAFE:
opt_specialflag|= SPECIAL_SAFE_MODE; opt_specialflag|= SPECIAL_SAFE_MODE;
......
...@@ -109,7 +109,7 @@ static int net_write_buff(NET *net,const char *packet,ulong len); ...@@ -109,7 +109,7 @@ static int net_write_buff(NET *net,const char *packet,ulong len);
int my_net_init(NET *net, Vio* vio) int my_net_init(NET *net, Vio* vio)
{ {
if (!(net->buff=(uchar*) my_malloc(net_buffer_length+ if (!(net->buff=(uchar*) my_malloc((uint32) net_buffer_length+
NET_HEADER_SIZE + COMP_HEADER_SIZE, NET_HEADER_SIZE + COMP_HEADER_SIZE,
MYF(MY_WME)))) MYF(MY_WME))))
return 1; return 1;
...@@ -162,7 +162,7 @@ static my_bool net_realloc(NET *net, ulong length) ...@@ -162,7 +162,7 @@ static my_bool net_realloc(NET *net, ulong length)
pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1); pkt_length = (length+IO_SIZE-1) & ~(IO_SIZE-1);
/* We must allocate some extra bytes for the end 0 and to be able to /* We must allocate some extra bytes for the end 0 and to be able to
read big compressed blocks */ read big compressed blocks */
if (!(buff=(uchar*) my_realloc((char*) net->buff, pkt_length + if (!(buff=(uchar*) my_realloc((char*) net->buff, (uint32) pkt_length +
NET_HEADER_SIZE + COMP_HEADER_SIZE, NET_HEADER_SIZE + COMP_HEADER_SIZE,
MYF(MY_WME)))) MYF(MY_WME))))
{ {
...@@ -189,7 +189,7 @@ void net_clear(NET *net) ...@@ -189,7 +189,7 @@ void net_clear(NET *net)
if (!vio_is_blocking(net->vio)) /* Safety if SSL */ if (!vio_is_blocking(net->vio)) /* Safety if SSL */
{ {
while ( (count = vio_read(net->vio, (char*) (net->buff), while ( (count = vio_read(net->vio, (char*) (net->buff),
net->max_packet)) > 0) (uint32) net->max_packet)) > 0)
DBUG_PRINT("info",("skipped %d bytes from file: %s", DBUG_PRINT("info",("skipped %d bytes from file: %s",
count,vio_description(net->vio))); count,vio_description(net->vio)));
if (is_blocking) if (is_blocking)
...@@ -243,7 +243,7 @@ my_net_write(NET *net,const char *packet,ulong len) ...@@ -243,7 +243,7 @@ my_net_write(NET *net,const char *packet,ulong len)
{ {
const ulong z_size = MAX_THREE_BYTES; const ulong z_size = MAX_THREE_BYTES;
int3store(buff, z_size); int3store(buff, z_size);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) || if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) ||
net_write_buff(net, packet, z_size)) net_write_buff(net, packet, z_size))
return 1; return 1;
...@@ -252,7 +252,7 @@ my_net_write(NET *net,const char *packet,ulong len) ...@@ -252,7 +252,7 @@ my_net_write(NET *net,const char *packet,ulong len)
} }
/* Write last packet */ /* Write last packet */
int3store(buff,len); int3store(buff,len);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE)) if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
return 1; return 1;
return net_write_buff(net,packet,len); return net_write_buff(net,packet,len);
...@@ -282,7 +282,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) ...@@ -282,7 +282,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
do do
{ {
int3store(buff, MAX_THREE_BYTES); int3store(buff, MAX_THREE_BYTES);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
if (net_write_buff(net,(char*) buff, header_size) || if (net_write_buff(net,(char*) buff, header_size) ||
net_write_buff(net,packet,len)) net_write_buff(net,packet,len))
return 1; return 1;
...@@ -294,7 +294,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) ...@@ -294,7 +294,7 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
len=length; /* Data left to be written */ len=length; /* Data left to be written */
} }
int3store(buff,length); int3store(buff,length);
buff[3]= net->pkt_nr++; buff[3]= (uchar) net->pkt_nr++;
return test(net_write_buff(net,(char*) buff,header_size) || return test(net_write_buff(net,(char*) buff,header_size) ||
net_write_buff(net,packet,len) || net_flush(net)); net_write_buff(net,packet,len) || net_flush(net));
} }
...@@ -357,8 +357,8 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -357,8 +357,8 @@ net_real_write(NET *net,const char *packet,ulong len)
ulong complen; ulong complen;
uchar *b; uchar *b;
uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE; uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE;
if (!(b=(uchar*) my_malloc(len + NET_HEADER_SIZE + COMP_HEADER_SIZE, if (!(b=(uchar*) my_malloc((uint32) len + NET_HEADER_SIZE +
MYF(MY_WME)))) COMP_HEADER_SIZE, MYF(MY_WME))))
{ {
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
net->last_errno=ER_OUT_OF_RESOURCES; net->last_errno=ER_OUT_OF_RESOURCES;
...@@ -395,7 +395,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -395,7 +395,7 @@ net_real_write(NET *net,const char *packet,ulong len)
pos=(char*) packet; end=pos+len; pos=(char*) packet; end=pos+len;
while (pos != end) while (pos != end)
{ {
if ((long) (length=vio_write(net->vio,pos,(ulong) (end-pos))) <= 0) if ((long) (length=vio_write(net->vio,pos,(uint32) (end-pos))) <= 0)
{ {
my_bool interrupted = vio_should_retry(net->vio); my_bool interrupted = vio_should_retry(net->vio);
#if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2)) #if (!defined(__WIN__) && !defined(__EMX__) && !defined(OS2))
...@@ -479,7 +479,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -479,7 +479,7 @@ net_real_write(NET *net,const char *packet,ulong len)
big packet big packet
*/ */
static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) static void my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed)
{ {
ALARM alarm_buff; ALARM alarm_buff;
uint retry_count=0; uint retry_count=0;
...@@ -502,7 +502,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed) ...@@ -502,7 +502,7 @@ static void my_net_skip_rest(NET *net, ulong remain, thr_alarm_t *alarmed)
} }
return; return;
} }
remain -= length; remain -= (uint32) length;
statistic_add(bytes_received,length,&LOCK_bytes_received); statistic_add(bytes_received,length,&LOCK_bytes_received);
} }
} }
...@@ -527,7 +527,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -527,7 +527,7 @@ my_real_read(NET *net, ulong *complen)
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
my_bool net_blocking=vio_is_blocking(net->vio); my_bool net_blocking=vio_is_blocking(net->vio);
ulong remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE : uint32 remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE :
NET_HEADER_SIZE); NET_HEADER_SIZE);
*complen = 0; *complen = 0;
...@@ -605,7 +605,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -605,7 +605,7 @@ my_real_read(NET *net, ulong *complen)
continue; continue;
} }
#endif #endif
DBUG_PRINT("error",("Couldn't read packet: remain: %d errno: %d length: %d alarmed: %d", remain,vio_errno(net->vio),length,alarmed)); DBUG_PRINT("error",("Couldn't read packet: remain: %lu errno: %d length: %ld alarmed: %d", remain,vio_errno(net->vio),length,alarmed));
len= packet_error; len= packet_error;
net->error=2; /* Close socket */ net->error=2; /* Close socket */
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
...@@ -614,7 +614,7 @@ my_real_read(NET *net, ulong *complen) ...@@ -614,7 +614,7 @@ my_real_read(NET *net, ulong *complen)
#endif #endif
goto end; goto end;
} }
remain -= (ulong) length; remain -= (uint32) length;
pos+= (ulong) length; pos+= (ulong) length;
statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received); statistic_add(bytes_received,(ulong) length,&LOCK_bytes_received);
} }
...@@ -661,14 +661,14 @@ my_real_read(NET *net, ulong *complen) ...@@ -661,14 +661,14 @@ my_real_read(NET *net, ulong *complen)
{ {
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
if (i == 1) if (i == 1)
my_net_skip_rest(net, len, &alarmed); my_net_skip_rest(net, (uint32) len, &alarmed);
#endif #endif
len= packet_error; /* Return error */ len= packet_error; /* Return error */
goto end; goto end;
} }
} }
pos=net->buff + net->where_b; pos=net->buff + net->where_b;
remain = len; remain = (uint32) len;
} }
} }
......
...@@ -48,9 +48,9 @@ class QUICK_RANGE :public Sql_alloc { ...@@ -48,9 +48,9 @@ class QUICK_RANGE :public Sql_alloc {
uint flag_arg) uint flag_arg)
: min_key((char*) sql_memdup(min_key_arg,min_length_arg+1)), : min_key((char*) sql_memdup(min_key_arg,min_length_arg+1)),
max_key((char*) sql_memdup(max_key_arg,max_length_arg+1)), max_key((char*) sql_memdup(max_key_arg,max_length_arg+1)),
min_length(min_length_arg), min_length((uint16) min_length_arg),
max_length(max_length_arg), max_length((uint16) max_length_arg),
flag(flag_arg) flag((uint16) flag_arg)
{} {}
}; };
......
This diff is collapsed.
This diff is collapsed.
...@@ -263,8 +263,8 @@ public: ...@@ -263,8 +263,8 @@ public:
delayed_insert *di; delayed_insert *di;
struct st_transactions { struct st_transactions {
IO_CACHE trans_log; IO_CACHE trans_log;
THD_TRANS all; /* Trans since BEGIN WORK */ THD_TRANS all; // Trans since BEGIN WORK
THD_TRANS stmt; /* Trans for current statement */ THD_TRANS stmt; // Trans for current statement
uint bdb_lock_count; uint bdb_lock_count;
} transaction; } transaction;
Item *free_list, *handler_items; Item *free_list, *handler_items;
...@@ -277,17 +277,20 @@ public: ...@@ -277,17 +277,20 @@ public:
Vio* active_vio; Vio* active_vio;
pthread_mutex_t active_vio_lock; pthread_mutex_t active_vio_lock;
#endif #endif
ulonglong next_insert_id,last_insert_id,current_insert_id, limit_found_rows; ulonglong next_insert_id,last_insert_id,current_insert_id,
limit_found_rows;
ha_rows select_limit,offset_limit,default_select_limit,cuted_fields, ha_rows select_limit,offset_limit,default_select_limit,cuted_fields,
max_join_size, sent_row_count, examined_row_count; max_join_size, sent_row_count, examined_row_count;
table_map used_tables; table_map used_tables;
ulong query_id,version, inactive_timeout,options,thread_id; ulong query_id,version, inactive_timeout,options,thread_id;
long dbug_thread_id; long dbug_thread_id;
pthread_t real_id; pthread_t real_id;
uint current_tablenr,tmp_table,cond_count,col_access,query_length; uint current_tablenr,tmp_table,cond_count,col_access;
uint server_status,open_options; uint server_status,open_options;
uint32 query_length;
enum_tx_isolation tx_isolation, session_tx_isolation; enum_tx_isolation tx_isolation, session_tx_isolation;
char scramble[9]; char scramble[9];
uint8 query_cache_type; // type of query cache processing
bool slave_thread; bool slave_thread;
bool set_query_id,locked,count_cuted_fields,some_tables_deleted; bool set_query_id,locked,count_cuted_fields,some_tables_deleted;
bool no_errors, allow_sum_func, password, fatal_error; bool no_errors, allow_sum_func, password, fatal_error;
...@@ -296,18 +299,18 @@ public: ...@@ -296,18 +299,18 @@ public:
bool query_error, bootstrap, cleanup_done; bool query_error, bootstrap, cleanup_done;
bool safe_to_cache_query; bool safe_to_cache_query;
bool volatile killed; bool volatile killed;
//type of query cache processing /*
byte query_cache_type; If we do a purge of binary logs, log index info of the threads
that are currently reading it needs to be adjusted. To do that
each thread that is using LOG_INFO needs to adjust the pointer to it
*/
LOG_INFO* current_linfo; LOG_INFO* current_linfo;
// if we do a purge of binary logs, log index info of the threads /*
// that are currently reading it needs to be adjusted. To do that In slave thread we need to know in behalf of which
// each thread that is using LOG_INFO needs to adjust the pointer to it thread the query is being run to replicate temp tables properly
*/
ulong slave_proxy_id; // in slave thread we need to know in behalf of which ulong slave_proxy_id;
// thread the query is being run to replicate temp tables properly NET* slave_net; // network connection from slave -> m.
NET* slave_net; // network connection from slave to master
THD(); THD();
~THD(); ~THD();
void cleanup(void); void cleanup(void);
......
...@@ -739,7 +739,7 @@ TABLE *delayed_insert::get_local_table(THD* client_thd) ...@@ -739,7 +739,7 @@ TABLE *delayed_insert::get_local_table(THD* client_thd)
} }
client_thd->proc_info="allocating local table"; client_thd->proc_info="allocating local table";
copy= (TABLE*) sql_alloc(sizeof(*copy)+ copy= (TABLE*) client_thd->alloc(sizeof(*copy)+
(table->fields+1)*sizeof(Field**)+ (table->fields+1)*sizeof(Field**)+
table->reclength); table->reclength);
if (!copy) if (!copy)
...@@ -759,7 +759,7 @@ TABLE *delayed_insert::get_local_table(THD* client_thd) ...@@ -759,7 +759,7 @@ TABLE *delayed_insert::get_local_table(THD* client_thd)
found_next_number_field=table->found_next_number_field; found_next_number_field=table->found_next_number_field;
for (org_field=table->field ; *org_field ; org_field++,field++) for (org_field=table->field ; *org_field ; org_field++,field++)
{ {
if (!(*field= (*org_field)->new_field(copy))) if (!(*field= (*org_field)->new_field(&client_thd->mem_root,copy)))
return 0; return 0;
(*field)->move_field(adjust_ptrs); // Point at copy->record[0] (*field)->move_field(adjust_ptrs); // Point at copy->record[0]
if (*org_field == found_next_number_field) if (*org_field == found_next_number_field)
......
This diff is collapsed.
...@@ -47,7 +47,8 @@ static void find_best(JOIN *join,table_map rest_tables,uint index, ...@@ -47,7 +47,8 @@ static void find_best(JOIN *join,table_map rest_tables,uint index,
static uint cache_record_length(JOIN *join,uint index); static uint cache_record_length(JOIN *join,uint index);
static double prev_record_reads(JOIN *join,table_map found_ref); static double prev_record_reads(JOIN *join,table_map found_ref);
static bool get_best_combination(JOIN *join); static bool get_best_combination(JOIN *join);
static store_key *get_store_key(KEYUSE *keyuse, table_map used_tables, static store_key *get_store_key(THD *thd,
KEYUSE *keyuse, table_map used_tables,
KEY_PART_INFO *key_part, char *key_buff, KEY_PART_INFO *key_part, char *key_buff,
uint maybe_null); uint maybe_null);
static bool make_simple_join(JOIN *join,TABLE *tmp_table); static bool make_simple_join(JOIN *join,TABLE *tmp_table);
...@@ -795,7 +796,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds, ...@@ -795,7 +796,7 @@ mysql_select(THD *thd,TABLE_LIST *tables,List<Item> &fields,COND *conds,
(procedure && (procedure->flags & PROC_GROUP))) (procedure && (procedure->flags & PROC_GROUP)))
{ {
alloc_group_fields(&join,group); alloc_group_fields(&join,group);
setup_copy_fields(&join.tmp_table_param,all_fields); setup_copy_fields(thd, &join.tmp_table_param,all_fields);
if (make_sum_func_list(&join,all_fields) || thd->fatal_error) if (make_sum_func_list(&join,all_fields) || thd->fatal_error)
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
} }
...@@ -2152,7 +2153,8 @@ get_best_combination(JOIN *join) ...@@ -2152,7 +2153,8 @@ get_best_combination(JOIN *join)
if (!keyuse->used_tables && if (!keyuse->used_tables &&
!(join->select_options & SELECT_DESCRIBE)) !(join->select_options & SELECT_DESCRIBE))
{ // Compare against constant { // Compare against constant
store_key_item *tmp=new store_key_item(keyinfo->key_part[i].field, store_key_item *tmp=new store_key_item(thd,
keyinfo->key_part[i].field,
(char*)key_buff + (char*)key_buff +
maybe_null, maybe_null,
maybe_null ? maybe_null ?
...@@ -2166,7 +2168,8 @@ get_best_combination(JOIN *join) ...@@ -2166,7 +2168,8 @@ get_best_combination(JOIN *join)
tmp->copy(); tmp->copy();
} }
else else
*ref_key++= get_store_key(keyuse,join->const_table_map, *ref_key++= get_store_key(join->thd,
keyuse,join->const_table_map,
&keyinfo->key_part[i], &keyinfo->key_part[i],
(char*) key_buff,maybe_null); (char*) key_buff,maybe_null);
key_buff+=keyinfo->key_part[i].store_length; key_buff+=keyinfo->key_part[i].store_length;
...@@ -2208,25 +2211,28 @@ get_best_combination(JOIN *join) ...@@ -2208,25 +2211,28 @@ get_best_combination(JOIN *join)
static store_key * static store_key *
get_store_key(KEYUSE *keyuse, table_map used_tables, KEY_PART_INFO *key_part, get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables,
char *key_buff, uint maybe_null) KEY_PART_INFO *key_part, char *key_buff, uint maybe_null)
{ {
if (!((~used_tables) & keyuse->used_tables)) // if const item if (!((~used_tables) & keyuse->used_tables)) // if const item
{ {
return new store_key_const_item(key_part->field, return new store_key_const_item(thd,
key_part->field,
key_buff + maybe_null, key_buff + maybe_null,
maybe_null ? key_buff : 0, maybe_null ? key_buff : 0,
key_part->length, key_part->length,
keyuse->val); keyuse->val);
} }
else if (keyuse->val->type() == Item::FIELD_ITEM) else if (keyuse->val->type() == Item::FIELD_ITEM)
return new store_key_field(key_part->field, return new store_key_field(thd,
key_part->field,
key_buff + maybe_null, key_buff + maybe_null,
maybe_null ? key_buff : 0, maybe_null ? key_buff : 0,
key_part->length, key_part->length,
((Item_field*) keyuse->val)->field, ((Item_field*) keyuse->val)->field,
keyuse->val->full_name()); keyuse->val->full_name());
return new store_key_item(key_part->field, return new store_key_item(thd,
key_part->field,
key_buff + maybe_null, key_buff + maybe_null,
maybe_null ? key_buff : 0, maybe_null ? key_buff : 0,
key_part->length, key_part->length,
...@@ -3272,7 +3278,7 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item) ...@@ -3272,7 +3278,7 @@ const_expression_in_where(COND *cond, Item *comp_item, Item **const_item)
** for send_fields ** for send_fields
****************************************************************************/ ****************************************************************************/
Field *create_tmp_field(TABLE *table,Item *item, Item::Type type, Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type,
Item_result_field ***copy_func, Field **from_field, Item_result_field ***copy_func, Field **from_field,
bool group, bool modify_item) bool group, bool modify_item)
{ {
...@@ -3314,7 +3320,7 @@ Field *create_tmp_field(TABLE *table,Item *item, Item::Type type, ...@@ -3314,7 +3320,7 @@ Field *create_tmp_field(TABLE *table,Item *item, Item::Type type,
item->name,table,item->binary); item->name,table,item->binary);
} }
} }
current_thd->fatal_error=1; thd->fatal_error=1;
return 0; // Error return 0; // Error
} }
case Item::FIELD_ITEM: case Item::FIELD_ITEM:
...@@ -3322,7 +3328,8 @@ Field *create_tmp_field(TABLE *table,Item *item, Item::Type type, ...@@ -3322,7 +3328,8 @@ Field *create_tmp_field(TABLE *table,Item *item, Item::Type type,
Field *org_field=((Item_field*) item)->field,*new_field; Field *org_field=((Item_field*) item)->field,*new_field;
*from_field=org_field; *from_field=org_field;
if ((new_field= org_field->new_field(table))) // Should always be true // The following should always be true
if ((new_field= org_field->new_field(&thd->mem_root,table)))
{ {
if (modify_item) if (modify_item)
((Item_field*) item)->result_field= new_field; ((Item_field*) item)->result_field= new_field;
...@@ -3510,8 +3517,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -3510,8 +3517,8 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (!arg->const_item()) if (!arg->const_item())
{ {
Field *new_field= Field *new_field=
create_tmp_field(table,arg,arg->type(),&copy_func,tmp_from_field, create_tmp_field(thd, table,arg,arg->type(),&copy_func,
group != 0,not_all_columns); tmp_from_field, group != 0,not_all_columns);
if (!new_field) if (!new_field)
goto err; // Should be OOM goto err; // Should be OOM
tmp_from_field++; tmp_from_field++;
...@@ -3527,7 +3534,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -3527,7 +3534,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
} }
else else
{ {
Field *new_field=create_tmp_field(table,item,type,&copy_func, Field *new_field=create_tmp_field(thd, table, item,type, &copy_func,
tmp_from_field, group != 0, tmp_from_field, group != 0,
not_all_columns); not_all_columns);
if (!new_field) if (!new_field)
...@@ -3708,7 +3715,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -3708,7 +3715,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
if (!using_unique_constraint) if (!using_unique_constraint)
{ {
group->buff=(char*) group_buff; group->buff=(char*) group_buff;
if (!(group->field=field->new_field(table))) if (!(group->field=field->new_field(&thd->mem_root,table)))
goto err; /* purecov: inspected */ goto err; /* purecov: inspected */
if (maybe_null) if (maybe_null)
{ {
...@@ -6410,7 +6417,7 @@ test_if_group_changed(List<Item_buff> &list) ...@@ -6410,7 +6417,7 @@ test_if_group_changed(List<Item_buff> &list)
*/ */
bool bool
setup_copy_fields(TMP_TABLE_PARAM *param,List<Item> &fields) setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, List<Item> &fields)
{ {
Item *pos; Item *pos;
List_iterator<Item> li(fields); List_iterator<Item> li(fields);
...@@ -6438,7 +6445,7 @@ setup_copy_fields(TMP_TABLE_PARAM *param,List<Item> &fields) ...@@ -6438,7 +6445,7 @@ setup_copy_fields(TMP_TABLE_PARAM *param,List<Item> &fields)
/* set up save buffer and change result_field to point at saved value */ /* set up save buffer and change result_field to point at saved value */
Field *field= item->field; Field *field= item->field;
item->result_field=field->new_field(field->table); item->result_field=field->new_field(&thd->mem_root,field->table);
char *tmp=(char*) sql_alloc(field->pack_length()+1); char *tmp=(char*) sql_alloc(field->pack_length()+1);
if (!tmp) if (!tmp)
goto err; goto err;
......
...@@ -190,7 +190,7 @@ TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, ...@@ -190,7 +190,7 @@ TABLE *create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields,
void free_tmp_table(THD *thd, TABLE *entry); void free_tmp_table(THD *thd, TABLE *entry);
void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields, void count_field_types(TMP_TABLE_PARAM *param, List<Item> &fields,
bool reset_with_sum_func); bool reset_with_sum_func);
bool setup_copy_fields(TMP_TABLE_PARAM *param,List<Item> &fields); bool setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param,List<Item> &fields);
void copy_fields(TMP_TABLE_PARAM *param); void copy_fields(TMP_TABLE_PARAM *param);
void copy_funcs(Item_result_field **func_ptr); void copy_funcs(Item_result_field **func_ptr);
bool create_myisam_from_heap(TABLE *table, TMP_TABLE_PARAM *param, int error, bool create_myisam_from_heap(TABLE *table, TMP_TABLE_PARAM *param, int error,
...@@ -210,7 +210,7 @@ class store_key :public Sql_alloc ...@@ -210,7 +210,7 @@ class store_key :public Sql_alloc
char *null_ptr; char *null_ptr;
char err; char err;
public: public:
store_key(Field *field_arg, char *ptr, char *null, uint length) store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length)
:null_ptr(null),err(0) :null_ptr(null),err(0)
{ {
if (field_arg->type() == FIELD_TYPE_BLOB) if (field_arg->type() == FIELD_TYPE_BLOB)
...@@ -219,7 +219,7 @@ class store_key :public Sql_alloc ...@@ -219,7 +219,7 @@ class store_key :public Sql_alloc
field_arg->table, field_arg->binary()); field_arg->table, field_arg->binary());
else else
{ {
to_field=field_arg->new_field(field_arg->table); to_field=field_arg->new_field(&thd->mem_root,field_arg->table);
if (to_field) if (to_field)
to_field->move_field(ptr, (uchar*) null, 1); to_field->move_field(ptr, (uchar*) null, 1);
} }
...@@ -235,9 +235,9 @@ class store_key_field: public store_key ...@@ -235,9 +235,9 @@ class store_key_field: public store_key
Copy_field copy_field; Copy_field copy_field;
const char *field_name; const char *field_name;
public: public:
store_key_field(Field *to_field_arg, char *ptr, char *null_ptr_arg, store_key_field(THD *thd, Field *to_field_arg, char *ptr, char *null_ptr_arg,
uint length, Field *from_field, const char *name_arg) uint length, Field *from_field, const char *name_arg)
:store_key(to_field_arg,ptr, :store_key(thd, to_field_arg,ptr,
null_ptr_arg ? null_ptr_arg : from_field->maybe_null() ? &err null_ptr_arg ? null_ptr_arg : from_field->maybe_null() ? &err
: NullS,length), field_name(name_arg) : NullS,length), field_name(name_arg)
{ {
...@@ -260,9 +260,9 @@ class store_key_item :public store_key ...@@ -260,9 +260,9 @@ class store_key_item :public store_key
protected: protected:
Item *item; Item *item;
public: public:
store_key_item(Field *to_field_arg, char *ptr, char *null_ptr_arg, store_key_item(THD *thd, Field *to_field_arg, char *ptr, char *null_ptr_arg,
uint length, Item *item_arg) uint length, Item *item_arg)
:store_key(to_field_arg,ptr, :store_key(thd, to_field_arg,ptr,
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ? null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
&err : NullS, length), item(item_arg) &err : NullS, length), item(item_arg)
{} {}
...@@ -279,10 +279,10 @@ class store_key_const_item :public store_key_item ...@@ -279,10 +279,10 @@ class store_key_const_item :public store_key_item
{ {
bool inited; bool inited;
public: public:
store_key_const_item(Field *to_field_arg, char *ptr, store_key_const_item(THD *thd, Field *to_field_arg, char *ptr,
char *null_ptr_arg, uint length, char *null_ptr_arg, uint length,
Item *item_arg) Item *item_arg)
:store_key_item(to_field_arg,ptr, :store_key_item(thd, to_field_arg,ptr,
null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ? null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ?
&err : NullS, length, item_arg), inited(0) &err : NullS, length, item_arg), inited(0)
{ {
......
...@@ -1054,9 +1054,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) ...@@ -1054,9 +1054,8 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose)
thd_info->query=0; thd_info->query=0;
if (tmp->query) if (tmp->query)
{ {
uint length=(uint) strlen(tmp->query); /* query_length is always set before tmp->query */
if (length > max_query_length) uint length= min(max_query_length, tmp->query_length);
length=max_query_length;
thd_info->query=(char*) thd->memdup(tmp->query,length+1); thd_info->query=(char*) thd->memdup(tmp->query,length+1);
thd_info->query[length]=0; thd_info->query[length]=0;
} }
......
...@@ -704,7 +704,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, ...@@ -704,7 +704,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
DBUG_RETURN(0); DBUG_RETURN(0);
} }
Field *field=create_tmp_field(&tmp_table,item,item->type(), Field *field=create_tmp_field(thd, &tmp_table, item, item->type(),
(Item_result_field***) 0, &tmp_field,0,0); (Item_result_field***) 0, &tmp_field,0,0);
if (!field || if (!field ||
!(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ? !(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ?
......
...@@ -467,7 +467,8 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -467,7 +467,8 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
key_part->key_part_flag|= HA_PART_KEY; key_part->key_part_flag|= HA_PART_KEY;
if (field->type() != FIELD_TYPE_BLOB) if (field->type() != FIELD_TYPE_BLOB)
{ // Create a new field { // Create a new field
field=key_part->field=field->new_field(outparam); field=key_part->field=field->new_field(&outparam->mem_root,
outparam);
field->field_length=key_part->length; field->field_length=key_part->length;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment