mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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)
This commit is contained in:
@@ -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
|
|||||||
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.
|
|||||||
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();
|
|||||||
@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
|
|||||||
@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
|
|||||||
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}.
|
|||||||
|
|
||||||
@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);
|
|||||||
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 */
|
|||||||
} 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
|
|||||||
#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);
|
|||||||
|
|
||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
}
|
}
|
||||||
/* 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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
}
|
}
|
||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
#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)
|
|||||||
{
|
{
|
||||||
#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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
209
sql/field.cc
209
sql/field.cc
@@ -219,14 +219,15 @@ static bool test_if_real(const char *str,int length)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
Field::Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
|
Field::Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
utype unireg_check_arg, const char *field_name_arg,
|
utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg)
|
||||||
:ptr(ptr_arg),null_ptr(null_ptr_arg),null_bit(null_bit_arg),
|
:ptr(ptr_arg),null_ptr(null_ptr_arg),
|
||||||
table(table_arg),query_id(0),key_start(0),part_of_key(0),part_of_sortkey(0),
|
table(table_arg),table_name(table_arg ? table_arg->table_name : 0),
|
||||||
table_name(table_arg ? table_arg->table_name : 0),
|
field_name(field_name_arg),
|
||||||
field_name(field_name_arg), unireg_check(unireg_check_arg),
|
query_id(0),key_start(0),part_of_key(0),part_of_sortkey(0),
|
||||||
field_length(length_arg)
|
unireg_check(unireg_check_arg),
|
||||||
|
field_length(length_arg),null_bit(null_bit_arg)
|
||||||
{
|
{
|
||||||
flags=null_ptr ? 0: NOT_NULL_FLAG;
|
flags=null_ptr ? 0: NOT_NULL_FLAG;
|
||||||
}
|
}
|
||||||
@@ -242,7 +243,7 @@ void Field::copy_from_tmp(int row_offset)
|
|||||||
memcpy(ptr,ptr+row_offset,pack_length());
|
memcpy(ptr,ptr+row_offset,pack_length());
|
||||||
if (null_ptr)
|
if (null_ptr)
|
||||||
{
|
{
|
||||||
*null_ptr= ((null_ptr[0] & (uchar) ~(uint) null_bit) |
|
*null_ptr= (uchar) ((null_ptr[0] & (uchar) ~(uint) null_bit) |
|
||||||
null_ptr[row_offset] & (uchar) null_bit);
|
null_ptr[row_offset] & (uchar) null_bit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1049,7 +1050,7 @@ void Field_short::sort_string(char *to,uint length __attribute__((unused)))
|
|||||||
if (unsigned_flag)
|
if (unsigned_flag)
|
||||||
to[0] = ptr[0];
|
to[0] = ptr[0];
|
||||||
else
|
else
|
||||||
to[0] = ptr[0] ^ 128; /* Revers signbit */
|
to[0] = (char) (ptr[0] ^ 128); /* Revers signbit */
|
||||||
to[1] = ptr[1];
|
to[1] = ptr[1];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1058,7 +1059,7 @@ void Field_short::sort_string(char *to,uint length __attribute__((unused)))
|
|||||||
if (unsigned_flag)
|
if (unsigned_flag)
|
||||||
to[0] = ptr[1];
|
to[0] = ptr[1];
|
||||||
else
|
else
|
||||||
to[0] = ptr[1] ^ 128; /* Revers signbit */
|
to[0] = (char) (ptr[1] ^ 128); /* Revers signbit */
|
||||||
to[1] = ptr[0];
|
to[1] = ptr[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1129,12 +1130,12 @@ void Field_medium::store(double nr)
|
|||||||
}
|
}
|
||||||
else if (nr >= (double) (long) (1L << 24))
|
else if (nr >= (double) (long) (1L << 24))
|
||||||
{
|
{
|
||||||
ulong tmp=(ulong) (1L << 24)-1L;
|
uint32 tmp=(uint32) (1L << 24)-1L;
|
||||||
int3store(ptr,tmp);
|
int3store(ptr,tmp);
|
||||||
current_thd->cuted_fields++;
|
current_thd->cuted_fields++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
int3store(ptr,(ulong) nr);
|
int3store(ptr,(uint32) nr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1171,7 +1172,7 @@ void Field_medium::store(longlong nr)
|
|||||||
current_thd->cuted_fields++;
|
current_thd->cuted_fields++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
int3store(ptr,(ulong) nr);
|
int3store(ptr,(uint32) nr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1449,7 +1450,7 @@ int Field_long::cmp(const char *a_ptr, const char *b_ptr)
|
|||||||
longget(b,b_ptr);
|
longget(b,b_ptr);
|
||||||
}
|
}
|
||||||
if (unsigned_flag)
|
if (unsigned_flag)
|
||||||
return ((ulong) a < (ulong) b) ? -1 : ((ulong) a > (ulong) b) ? 1 : 0;
|
return ((uint32) a < (uint32) b) ? -1 : ((uint32) a > (uint32) b) ? 1 : 0;
|
||||||
return (a < b) ? -1 : (a > b) ? 1 : 0;
|
return (a < b) ? -1 : (a > b) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1461,7 +1462,7 @@ void Field_long::sort_string(char *to,uint length __attribute__((unused)))
|
|||||||
if (unsigned_flag)
|
if (unsigned_flag)
|
||||||
to[0] = ptr[0];
|
to[0] = ptr[0];
|
||||||
else
|
else
|
||||||
to[0] = ptr[0] ^ 128; /* Revers signbit */
|
to[0] = (char) (ptr[0] ^ 128); /* Revers signbit */
|
||||||
to[1] = ptr[1];
|
to[1] = ptr[1];
|
||||||
to[2] = ptr[2];
|
to[2] = ptr[2];
|
||||||
to[3] = ptr[3];
|
to[3] = ptr[3];
|
||||||
@@ -1472,7 +1473,7 @@ void Field_long::sort_string(char *to,uint length __attribute__((unused)))
|
|||||||
if (unsigned_flag)
|
if (unsigned_flag)
|
||||||
to[0] = ptr[3];
|
to[0] = ptr[3];
|
||||||
else
|
else
|
||||||
to[0] = ptr[3] ^ 128; /* Revers signbit */
|
to[0] = (char) (ptr[3] ^ 128); /* Revers signbit */
|
||||||
to[1] = ptr[2];
|
to[1] = ptr[2];
|
||||||
to[2] = ptr[1];
|
to[2] = ptr[1];
|
||||||
to[3] = ptr[0];
|
to[3] = ptr[0];
|
||||||
@@ -1660,7 +1661,7 @@ void Field_longlong::sort_string(char *to,uint length __attribute__((unused)))
|
|||||||
if (unsigned_flag)
|
if (unsigned_flag)
|
||||||
to[0] = ptr[0];
|
to[0] = ptr[0];
|
||||||
else
|
else
|
||||||
to[0] = ptr[0] ^ 128; /* Revers signbit */
|
to[0] = (char) (ptr[0] ^ 128); /* Revers signbit */
|
||||||
to[1] = ptr[1];
|
to[1] = ptr[1];
|
||||||
to[2] = ptr[2];
|
to[2] = ptr[2];
|
||||||
to[3] = ptr[3];
|
to[3] = ptr[3];
|
||||||
@@ -1675,7 +1676,7 @@ void Field_longlong::sort_string(char *to,uint length __attribute__((unused)))
|
|||||||
if (unsigned_flag)
|
if (unsigned_flag)
|
||||||
to[0] = ptr[7];
|
to[0] = ptr[7];
|
||||||
else
|
else
|
||||||
to[0] = ptr[7] ^ 128; /* Revers signbit */
|
to[0] = (char) (ptr[7] ^ 128); /* Revers signbit */
|
||||||
to[1] = ptr[6];
|
to[1] = ptr[6];
|
||||||
to[2] = ptr[5];
|
to[2] = ptr[5];
|
||||||
to[3] = ptr[4];
|
to[3] = ptr[4];
|
||||||
@@ -1910,7 +1911,7 @@ void Field_float::sort_string(char *to,uint length __attribute__((unused)))
|
|||||||
{ /* make complement */
|
{ /* make complement */
|
||||||
uint i;
|
uint i;
|
||||||
for (i=0 ; i < sizeof(nr); i++)
|
for (i=0 ; i < sizeof(nr); i++)
|
||||||
tmp[i]=tmp[i] ^ (uchar) 255;
|
tmp[i]= (uchar) (tmp[i] ^ (uchar) 255);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -2278,10 +2279,10 @@ void Field_timestamp::store(longlong nr)
|
|||||||
{
|
{
|
||||||
part1=(long) (nr/LL(1000000));
|
part1=(long) (nr/LL(1000000));
|
||||||
part2=(long) (nr - (longlong) part1*LL(1000000));
|
part2=(long) (nr - (longlong) part1*LL(1000000));
|
||||||
l_time.year= part1/10000L; part1%=10000L;
|
l_time.year= (int) (part1/10000L); part1%=10000L;
|
||||||
l_time.month= (int) part1 / 100;
|
l_time.month= (int) part1 / 100;
|
||||||
l_time.day= (int) part1 % 100;
|
l_time.day= (int) part1 % 100;
|
||||||
l_time.hour= part2/10000L; part2%=10000L;
|
l_time.hour= (int) (part2/10000L); part2%=10000L;
|
||||||
l_time.minute=(int) part2 / 100;
|
l_time.minute=(int) part2 / 100;
|
||||||
l_time.second=(int) part2 % 100;
|
l_time.second=(int) part2 % 100;
|
||||||
timestamp=my_gmt_sec(&l_time);
|
timestamp=my_gmt_sec(&l_time);
|
||||||
@@ -2295,7 +2296,7 @@ void Field_timestamp::store(longlong nr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
longstore(ptr,(ulong)timestamp);
|
longstore(ptr,(uint32) timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -2596,7 +2597,7 @@ void Field_time::store(longlong nr)
|
|||||||
|
|
||||||
double Field_time::val_real(void)
|
double Field_time::val_real(void)
|
||||||
{
|
{
|
||||||
ulong j= (ulong) uint3korr(ptr);
|
uint32 j= (uint32) uint3korr(ptr);
|
||||||
return (double) j;
|
return (double) j;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2632,19 +2633,19 @@ bool Field_time::get_time(TIME *ltime)
|
|||||||
ltime->neg= 1;
|
ltime->neg= 1;
|
||||||
tmp=-tmp;
|
tmp=-tmp;
|
||||||
}
|
}
|
||||||
ltime->hour=tmp/10000;
|
ltime->hour= (int) (tmp/10000);
|
||||||
tmp-=ltime->hour*10000;
|
tmp-=ltime->hour*10000;
|
||||||
ltime->minute= tmp/100;
|
ltime->minute= (int) tmp/100;
|
||||||
ltime->second= tmp % 100;
|
ltime->second= (int) tmp % 100;
|
||||||
ltime->second_part=0;
|
ltime->second_part=0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Field_time::cmp(const char *a_ptr, const char *b_ptr)
|
int Field_time::cmp(const char *a_ptr, const char *b_ptr)
|
||||||
{
|
{
|
||||||
long a,b;
|
int32 a,b;
|
||||||
a=(long) sint3korr(a_ptr);
|
a=(int32) sint3korr(a_ptr);
|
||||||
b=(long) sint3korr(b_ptr);
|
b=(int32) sint3korr(b_ptr);
|
||||||
return (a < b) ? -1 : (a > b) ? 1 : 0;
|
return (a < b) ? -1 : (a > b) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2758,11 +2759,11 @@ void Field_year::sql_type(String &res) const
|
|||||||
void Field_date::store(const char *from, uint len)
|
void Field_date::store(const char *from, uint len)
|
||||||
{
|
{
|
||||||
TIME l_time;
|
TIME l_time;
|
||||||
ulong tmp;
|
uint32 tmp;
|
||||||
if (str_to_TIME(from,len,&l_time,1) == TIMESTAMP_NONE)
|
if (str_to_TIME(from,len,&l_time,1) == TIMESTAMP_NONE)
|
||||||
tmp=0;
|
tmp=0;
|
||||||
else
|
else
|
||||||
tmp=(ulong) l_time.year*10000L + (ulong) (l_time.month*100+l_time.day);
|
tmp=(uint32) l_time.year*10000L + (uint32) (l_time.month*100+l_time.day);
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef WORDS_BIGENDIAN
|
||||||
if (table->db_low_byte_first)
|
if (table->db_low_byte_first)
|
||||||
{
|
{
|
||||||
@@ -2934,7 +2935,7 @@ void Field_newdate::store(double nr)
|
|||||||
|
|
||||||
void Field_newdate::store(longlong nr)
|
void Field_newdate::store(longlong nr)
|
||||||
{
|
{
|
||||||
long tmp;
|
int32 tmp;
|
||||||
if (nr >= LL(100000000) && nr <= LL(99991231235959))
|
if (nr >= LL(100000000) && nr <= LL(99991231235959))
|
||||||
nr=nr/LL(1000000); // Timestamp to date
|
nr=nr/LL(1000000); // Timestamp to date
|
||||||
if (nr < 0L || nr > 99991231L)
|
if (nr < 0L || nr > 99991231L)
|
||||||
@@ -2944,16 +2945,16 @@ void Field_newdate::store(longlong nr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tmp=(long) nr;
|
tmp=(int32) nr;
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
if (tmp < YY_PART_YEAR*10000L) // Fix short dates
|
if (tmp < YY_PART_YEAR*10000L) // Fix short dates
|
||||||
tmp+=20000000L;
|
tmp+= (uint32) 20000000L;
|
||||||
else if (tmp < 999999L)
|
else if (tmp < 999999L)
|
||||||
tmp+=19000000L;
|
tmp+= (uint32) 19000000L;
|
||||||
}
|
}
|
||||||
uint month=((tmp/100) % 100);
|
uint month= (uint) ((tmp/100) % 100);
|
||||||
uint day= tmp%100;
|
uint day= (uint) (tmp%100);
|
||||||
if (month > 12 || day > 31)
|
if (month > 12 || day > 31)
|
||||||
{
|
{
|
||||||
tmp=0L; // Don't allow date to change
|
tmp=0L; // Don't allow date to change
|
||||||
@@ -2962,7 +2963,7 @@ void Field_newdate::store(longlong nr)
|
|||||||
else
|
else
|
||||||
tmp= day + month*32 + (tmp/10000)*16*32;
|
tmp= day + month*32 + (tmp/10000)*16*32;
|
||||||
}
|
}
|
||||||
int3store(ptr,tmp);
|
int3store(ptr,(int32) tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Field_newdate::store_time(TIME *ltime,timestamp_type type)
|
void Field_newdate::store_time(TIME *ltime,timestamp_type type)
|
||||||
@@ -2997,25 +2998,25 @@ String *Field_newdate::val_str(String *val_buffer,
|
|||||||
{
|
{
|
||||||
val_buffer->alloc(field_length);
|
val_buffer->alloc(field_length);
|
||||||
val_buffer->length(field_length);
|
val_buffer->length(field_length);
|
||||||
ulong tmp=(ulong) uint3korr(ptr);
|
uint32 tmp=(uint32) uint3korr(ptr);
|
||||||
int part;
|
int part;
|
||||||
char *pos=(char*) val_buffer->ptr()+10;
|
char *pos=(char*) val_buffer->ptr()+10;
|
||||||
|
|
||||||
/* Open coded to get more speed */
|
/* Open coded to get more speed */
|
||||||
*pos--=0;
|
*pos--=0; // End NULL
|
||||||
part=(int) (tmp & 31);
|
part=(int) (tmp & 31);
|
||||||
*pos--='0'+part%10;
|
*pos--= (char) ('0'+part%10);
|
||||||
*pos--='0'+part/10;
|
*pos--= (char) ('0'+part/10);
|
||||||
*pos--= '-';
|
*pos--= '-';
|
||||||
part=(int) (tmp >> 5 & 15);
|
part=(int) (tmp >> 5 & 15);
|
||||||
*pos--='0'+part%10;
|
*pos--= (char) ('0'+part%10);
|
||||||
*pos--='0'+part/10;
|
*pos--= (char) ('0'+part/10);
|
||||||
*pos--= '-';
|
*pos--= '-';
|
||||||
part=(int) (tmp >> 9);
|
part=(int) (tmp >> 9);
|
||||||
*pos--='0'+part%10; part/=10;
|
*pos--= (char) ('0'+part%10); part/=10;
|
||||||
*pos--='0'+part%10; part/=10;
|
*pos--= (char) ('0'+part%10); part/=10;
|
||||||
*pos--='0'+part%10; part/=10;
|
*pos--= (char) ('0'+part%10); part/=10;
|
||||||
*pos='0'+part;
|
*pos= (char) ('0'+part);
|
||||||
return val_buffer;
|
return val_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3023,7 +3024,7 @@ bool Field_newdate::get_date(TIME *ltime,bool fuzzydate)
|
|||||||
{
|
{
|
||||||
if (is_null())
|
if (is_null())
|
||||||
return 1;
|
return 1;
|
||||||
ulong tmp=(ulong) uint3korr(ptr);
|
uint32 tmp=(uint32) uint3korr(ptr);
|
||||||
bzero((char*) ltime,sizeof(*ltime));
|
bzero((char*) ltime,sizeof(*ltime));
|
||||||
ltime->day= tmp & 31;
|
ltime->day= tmp & 31;
|
||||||
ltime->month= (tmp >> 5) & 15;
|
ltime->month= (tmp >> 5) & 15;
|
||||||
@@ -3039,9 +3040,9 @@ bool Field_newdate::get_time(TIME *ltime)
|
|||||||
|
|
||||||
int Field_newdate::cmp(const char *a_ptr, const char *b_ptr)
|
int Field_newdate::cmp(const char *a_ptr, const char *b_ptr)
|
||||||
{
|
{
|
||||||
ulong a,b;
|
uint32 a,b;
|
||||||
a=(ulong) uint3korr(a_ptr);
|
a=(uint32) uint3korr(a_ptr);
|
||||||
b=(ulong) uint3korr(b_ptr);
|
b=(uint32) uint3korr(b_ptr);
|
||||||
return (a < b) ? -1 : (a > b) ? 1 : 0;
|
return (a < b) ? -1 : (a > b) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3175,44 +3176,44 @@ String *Field_datetime::val_str(String *val_buffer,
|
|||||||
|
|
||||||
pos=(char*) val_buffer->ptr()+19;
|
pos=(char*) val_buffer->ptr()+19;
|
||||||
*pos--=0;
|
*pos--=0;
|
||||||
*pos--='0'+(char) (part2%10); part2/=10;
|
*pos--= (char) ('0'+(char) (part2%10)); part2/=10;
|
||||||
*pos--='0'+(char) (part2%10); part3= (int) (part2 / 10);
|
*pos--= (char) ('0'+(char) (part2%10)); part3= (int) (part2 / 10);
|
||||||
*pos--= ':';
|
*pos--= ':';
|
||||||
*pos--='0'+(char) (part3%10); part3/=10;
|
*pos--= (char) ('0'+(char) (part3%10)); part3/=10;
|
||||||
*pos--='0'+(char) (part3%10); part3/=10;
|
*pos--= (char) ('0'+(char) (part3%10)); part3/=10;
|
||||||
*pos--= ':';
|
*pos--= ':';
|
||||||
*pos--='0'+(char) (part3%10); part3/=10;
|
*pos--= (char) ('0'+(char) (part3%10)); part3/=10;
|
||||||
*pos--='0'+(char) part3;
|
*pos--= (char) ('0'+(char) part3);
|
||||||
*pos--= ' ';
|
*pos--= ' ';
|
||||||
*pos--='0'+(char) (part1%10); part1/=10;
|
*pos--= (char) ('0'+(char) (part1%10)); part1/=10;
|
||||||
*pos--='0'+(char) (part1%10); part1/=10;
|
*pos--= (char) ('0'+(char) (part1%10)); part1/=10;
|
||||||
*pos--= '-';
|
*pos--= '-';
|
||||||
*pos--='0'+(char) (part1%10); part1/=10;
|
*pos--= (char) ('0'+(char) (part1%10)); part1/=10;
|
||||||
*pos--='0'+(char) (part1%10); part3= (int) (part1/10);
|
*pos--= (char) ('0'+(char) (part1%10)); part3= (int) (part1/10);
|
||||||
*pos--= '-';
|
*pos--= '-';
|
||||||
*pos--='0'+(char) (part3%10); part3/=10;
|
*pos--= (char) ('0'+(char) (part3%10)); part3/=10;
|
||||||
*pos--='0'+(char) (part3%10); part3/=10;
|
*pos--= (char) ('0'+(char) (part3%10)); part3/=10;
|
||||||
*pos--='0'+(char) (part3%10); part3/=10;
|
*pos--= (char) ('0'+(char) (part3%10)); part3/=10;
|
||||||
*pos='0'+(char) part3;
|
*pos=(char) ('0'+(char) part3);
|
||||||
return val_buffer;
|
return val_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Field_datetime::get_date(TIME *ltime,bool fuzzydate)
|
bool Field_datetime::get_date(TIME *ltime,bool fuzzydate)
|
||||||
{
|
{
|
||||||
longlong tmp=Field_datetime::val_int();
|
longlong tmp=Field_datetime::val_int();
|
||||||
long part1,part2;
|
uint32 part1,part2;
|
||||||
part1=(long) (tmp/LL(1000000));
|
part1=(uint32) (tmp/LL(1000000));
|
||||||
part2=(long) (tmp - (ulonglong) part1*LL(1000000));
|
part2=(uint32) (tmp - (ulonglong) part1*LL(1000000));
|
||||||
|
|
||||||
ltime->time_type= TIMESTAMP_FULL;
|
ltime->time_type= TIMESTAMP_FULL;
|
||||||
ltime->neg= 0;
|
ltime->neg= 0;
|
||||||
ltime->second_part= 0;
|
ltime->second_part= 0;
|
||||||
ltime->second= part2%100;
|
ltime->second= (int) (part2%100);
|
||||||
ltime->minute= part2/100%100;
|
ltime->minute= (int) (part2/100%100);
|
||||||
ltime->hour= part2/10000;
|
ltime->hour= (int) (part2/10000);
|
||||||
ltime->day= part1%100;
|
ltime->day= (int) (part1%100);
|
||||||
ltime->month= part1/100%100;
|
ltime->month= (int) (part1/100%100);
|
||||||
ltime->year= part1/10000;
|
ltime->year= (int) (part1/10000);
|
||||||
return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0;
|
return (!fuzzydate && (!ltime->month || !ltime->day)) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3331,7 +3332,7 @@ void Field_string::store(longlong nr)
|
|||||||
{
|
{
|
||||||
char buff[22];
|
char buff[22];
|
||||||
char *end=longlong10_to_str(nr,buff,-10);
|
char *end=longlong10_to_str(nr,buff,-10);
|
||||||
Field_string::store(buff,end-buff);
|
Field_string::store(buff,(uint) (end-buff));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3522,7 +3523,7 @@ void Field_varstring::store(longlong nr)
|
|||||||
{
|
{
|
||||||
char buff[22];
|
char buff[22];
|
||||||
char *end=longlong10_to_str(nr,buff,-10);
|
char *end=longlong10_to_str(nr,buff,-10);
|
||||||
Field_varstring::store(buff,end-buff);
|
Field_varstring::store(buff,(uint) (end-buff));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3613,9 +3614,9 @@ char *Field_varstring::pack(char *to, const char *from, uint max_length)
|
|||||||
uint length=uint2korr(from);
|
uint length=uint2korr(from);
|
||||||
if (length > max_length)
|
if (length > max_length)
|
||||||
length=max_length;
|
length=max_length;
|
||||||
*to++= (length & 255);
|
*to++= (char) (length & 255);
|
||||||
if (max_length > 255)
|
if (max_length > 255)
|
||||||
*to++= (uchar) (length >> 8);
|
*to++= (char) (length >> 8);
|
||||||
if (length)
|
if (length)
|
||||||
memcpy(to, from+2, length);
|
memcpy(to, from+2, length);
|
||||||
return to+length;
|
return to+length;
|
||||||
@@ -3704,7 +3705,7 @@ uint Field_varstring::max_packed_col_length(uint max_length)
|
|||||||
** packlength slot and may be from 1-4.
|
** packlength slot and may be from 1-4.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
|
Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,uint blob_pack_length,
|
struct st_table *table_arg,uint blob_pack_length,
|
||||||
bool binary_arg)
|
bool binary_arg)
|
||||||
@@ -3721,7 +3722,7 @@ Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Field_blob::store_length(ulong number)
|
void Field_blob::store_length(uint32 number)
|
||||||
{
|
{
|
||||||
switch (packlength) {
|
switch (packlength) {
|
||||||
case 1:
|
case 1:
|
||||||
@@ -3748,9 +3749,9 @@ void Field_blob::store_length(ulong number)
|
|||||||
shortstore(ptr,(unsigned short) number);
|
shortstore(ptr,(unsigned short) number);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (number > (ulong) (1L << 24))
|
if (number > (uint32) (1L << 24))
|
||||||
{
|
{
|
||||||
number= (ulong) (1L << 24)-1L;
|
number= (uint32) (1L << 24)-1L;
|
||||||
current_thd->cuted_fields++;
|
current_thd->cuted_fields++;
|
||||||
}
|
}
|
||||||
int3store(ptr,number);
|
int3store(ptr,number);
|
||||||
@@ -3768,11 +3769,11 @@ void Field_blob::store_length(ulong number)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ulong Field_blob::get_length(const char *pos)
|
uint32 Field_blob::get_length(const char *pos)
|
||||||
{
|
{
|
||||||
switch (packlength) {
|
switch (packlength) {
|
||||||
case 1:
|
case 1:
|
||||||
return (ulong) (uchar) pos[0];
|
return (uint32) (uchar) pos[0];
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
uint16 tmp;
|
uint16 tmp;
|
||||||
@@ -3782,10 +3783,10 @@ ulong Field_blob::get_length(const char *pos)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
shortget(tmp,pos);
|
shortget(tmp,pos);
|
||||||
return (ulong) tmp;
|
return (uint32) tmp;
|
||||||
}
|
}
|
||||||
case 3:
|
case 3:
|
||||||
return (ulong) uint3korr(pos);
|
return (uint32) uint3korr(pos);
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
uint32 tmp;
|
uint32 tmp;
|
||||||
@@ -3795,7 +3796,7 @@ ulong Field_blob::get_length(const char *pos)
|
|||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
longget(tmp,pos);
|
longget(tmp,pos);
|
||||||
return (ulong) tmp;
|
return (uint32) tmp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0; // Impossible
|
return 0; // Impossible
|
||||||
@@ -3841,14 +3842,14 @@ void Field_blob::store(const char *from,uint len)
|
|||||||
void Field_blob::store(double nr)
|
void Field_blob::store(double nr)
|
||||||
{
|
{
|
||||||
value.set(nr);
|
value.set(nr);
|
||||||
Field_blob::store(value.ptr(),value.length());
|
Field_blob::store(value.ptr(),(uint) value.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Field_blob::store(longlong nr)
|
void Field_blob::store(longlong nr)
|
||||||
{
|
{
|
||||||
value.set(nr);
|
value.set(nr);
|
||||||
Field_blob::store(value.ptr(),value.length());
|
Field_blob::store(value.ptr(), (uint) value.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -3859,7 +3860,7 @@ double Field_blob::val_real(void)
|
|||||||
memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
|
memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
|
||||||
if (!blob)
|
if (!blob)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
ulong length=get_length(ptr);
|
uint32 length=get_length(ptr);
|
||||||
|
|
||||||
char save=blob[length]; // Ok to patch blob in NISAM
|
char save=blob[length]; // Ok to patch blob in NISAM
|
||||||
blob[length]=0;
|
blob[length]=0;
|
||||||
@@ -3875,7 +3876,7 @@ longlong Field_blob::val_int(void)
|
|||||||
memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
|
memcpy_fixed(&blob,ptr+packlength,sizeof(char*));
|
||||||
if (!blob)
|
if (!blob)
|
||||||
return 0;
|
return 0;
|
||||||
ulong length=get_length(ptr);
|
uint32 length=get_length(ptr);
|
||||||
|
|
||||||
char save=blob[length]; // Ok to patch blob in NISAM
|
char save=blob[length]; // Ok to patch blob in NISAM
|
||||||
blob[length]=0;
|
blob[length]=0;
|
||||||
@@ -3898,8 +3899,8 @@ String *Field_blob::val_str(String *val_buffer __attribute__((unused)),
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int Field_blob::cmp(const char *a,ulong a_length, const char *b,
|
int Field_blob::cmp(const char *a,uint32 a_length, const char *b,
|
||||||
ulong b_length)
|
uint32 b_length)
|
||||||
{
|
{
|
||||||
int diff;
|
int diff;
|
||||||
if (binary_flag)
|
if (binary_flag)
|
||||||
@@ -3933,11 +3934,11 @@ int Field_blob::cmp_binary_offset(uint row_offset)
|
|||||||
|
|
||||||
|
|
||||||
int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr,
|
int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr,
|
||||||
ulong max_length)
|
uint32 max_length)
|
||||||
{
|
{
|
||||||
char *a,*b;
|
char *a,*b;
|
||||||
uint diff;
|
uint diff;
|
||||||
ulong a_length,b_length;
|
uint32 a_length,b_length;
|
||||||
memcpy_fixed(&a,a_ptr+packlength,sizeof(char*));
|
memcpy_fixed(&a,a_ptr+packlength,sizeof(char*));
|
||||||
memcpy_fixed(&b,b_ptr+packlength,sizeof(char*));
|
memcpy_fixed(&b,b_ptr+packlength,sizeof(char*));
|
||||||
a_length=get_length(a_ptr);
|
a_length=get_length(a_ptr);
|
||||||
@@ -3956,9 +3957,9 @@ int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr,
|
|||||||
void Field_blob::get_key_image(char *buff,uint length)
|
void Field_blob::get_key_image(char *buff,uint length)
|
||||||
{
|
{
|
||||||
length-=HA_KEY_BLOB_LENGTH;
|
length-=HA_KEY_BLOB_LENGTH;
|
||||||
ulong blob_length=get_length(ptr);
|
uint32 blob_length=get_length(ptr);
|
||||||
char *blob;
|
char *blob;
|
||||||
if ((ulong) length > blob_length)
|
if ((uint32) length > blob_length)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_purify
|
#ifdef HAVE_purify
|
||||||
bzero(buff+2+blob_length, (length-blob_length));
|
bzero(buff+2+blob_length, (length-blob_length));
|
||||||
@@ -4052,7 +4053,7 @@ char *Field_blob::pack(char *to, const char *from, uint max_length)
|
|||||||
{
|
{
|
||||||
char *save=ptr;
|
char *save=ptr;
|
||||||
ptr=(char*) from;
|
ptr=(char*) from;
|
||||||
ulong length=get_length(); // Length of from string
|
uint32 length=get_length(); // Length of from string
|
||||||
if (length > max_length)
|
if (length > max_length)
|
||||||
{
|
{
|
||||||
ptr=to;
|
ptr=to;
|
||||||
@@ -4075,7 +4076,7 @@ char *Field_blob::pack(char *to, const char *from, uint max_length)
|
|||||||
const char *Field_blob::unpack(char *to, const char *from)
|
const char *Field_blob::unpack(char *to, const char *from)
|
||||||
{
|
{
|
||||||
memcpy(to,from,packlength);
|
memcpy(to,from,packlength);
|
||||||
ulong length=get_length(from);
|
uint32 length=get_length(from);
|
||||||
from+=packlength;
|
from+=packlength;
|
||||||
if (length)
|
if (length)
|
||||||
memcpy_fixed(to+packlength, &from, sizeof(from));
|
memcpy_fixed(to+packlength, &from, sizeof(from));
|
||||||
@@ -4140,7 +4141,7 @@ char *Field_blob::pack_key(char *to, const char *from, uint max_length)
|
|||||||
{
|
{
|
||||||
char *save=ptr;
|
char *save=ptr;
|
||||||
ptr=(char*) from;
|
ptr=(char*) from;
|
||||||
ulong length=get_length(); // Length of from string
|
uint32 length=get_length(); // Length of from string
|
||||||
if (length > max_length)
|
if (length > max_length)
|
||||||
length=max_length;
|
length=max_length;
|
||||||
*to++= (uchar) length;
|
*to++= (uchar) length;
|
||||||
@@ -4163,9 +4164,9 @@ char *Field_blob::pack_key_from_key_image(char *to, const char *from,
|
|||||||
uint length=uint2korr(from);
|
uint length=uint2korr(from);
|
||||||
if (length > max_length)
|
if (length > max_length)
|
||||||
length=max_length;
|
length=max_length;
|
||||||
*to++= (length & 255);
|
*to++= (char) (length & 255);
|
||||||
if (max_length > 255)
|
if (max_length > 255)
|
||||||
*to++= (uchar) (length >> 8);
|
*to++= (char) (length >> 8);
|
||||||
if (length)
|
if (length)
|
||||||
memcpy(to, from+2, length);
|
memcpy(to, from+2, length);
|
||||||
return to+length;
|
return to+length;
|
||||||
@@ -4278,7 +4279,7 @@ void Field_enum::store(const char *from,uint length)
|
|||||||
conv=buff;
|
conv=buff;
|
||||||
}
|
}
|
||||||
my_errno=0;
|
my_errno=0;
|
||||||
tmp=strtoul(conv,&end,10);
|
tmp=(uint) strtoul(conv,&end,10);
|
||||||
if (my_errno || end != conv+length || tmp > typelib->count)
|
if (my_errno || end != conv+length || tmp > typelib->count)
|
||||||
{
|
{
|
||||||
tmp=0;
|
tmp=0;
|
||||||
@@ -4624,7 +4625,7 @@ uint pack_length_to_packflag(uint type)
|
|||||||
|
|
||||||
|
|
||||||
Field *make_field(char *ptr, uint32 field_length,
|
Field *make_field(char *ptr, uint32 field_length,
|
||||||
uchar *null_pos, uint null_bit,
|
uchar *null_pos, uchar null_bit,
|
||||||
uint pack_flag,
|
uint pack_flag,
|
||||||
Field::utype unireg_check,
|
Field::utype unireg_check,
|
||||||
TYPELIB *interval,
|
TYPELIB *interval,
|
||||||
|
104
sql/field.h
104
sql/field.h
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Because of the function new_field all field classes that have static
|
Because of the function new_field() all field classes that have static
|
||||||
** variables must declare the size_of() member function.
|
variables must declare the size_of() member function.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
@@ -37,21 +37,22 @@ public:
|
|||||||
static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
|
static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); }
|
||||||
static void operator delete(void *ptr_arg, size_t size) {} /*lint -e715 */
|
static void operator delete(void *ptr_arg, size_t size) {} /*lint -e715 */
|
||||||
|
|
||||||
|
char *ptr; // Position to field in record
|
||||||
|
uchar *null_ptr; // Byte where null_bit is
|
||||||
|
struct st_table *table; // Pointer for table
|
||||||
|
const char *table_name,*field_name;
|
||||||
|
ulong query_id; // For quick test of used fields
|
||||||
|
// Field is part of the following keys
|
||||||
|
key_map key_start,part_of_key,part_of_sortkey;
|
||||||
enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL,
|
enum utype { NONE,DATE,SHIELD,NOEMPTY,CASEUP,PNR,BGNR,PGNR,YES,NO,REL,
|
||||||
CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,
|
CHECK,EMPTY,UNKNOWN_FIELD,CASEDN,NEXT_NUMBER,INTERVAL_FIELD,
|
||||||
BIT_FIELD, TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD};
|
BIT_FIELD, TIMESTAMP_FIELD,CAPITALIZE,BLOB_FIELD};
|
||||||
char *ptr; // Position to field in record
|
|
||||||
uchar *null_ptr; // Byte where null_bit is
|
|
||||||
uint8 null_bit; // And position to it
|
|
||||||
struct st_table *table; // Pointer for table
|
|
||||||
ulong query_id; // For quick test of used fields
|
|
||||||
key_map key_start,part_of_key,part_of_sortkey;// Field is part of these keys.
|
|
||||||
const char *table_name,*field_name;
|
|
||||||
utype unireg_check;
|
utype unireg_check;
|
||||||
uint32 field_length; // Length of field
|
uint32 field_length; // Length of field
|
||||||
uint16 flags;
|
uint16 flags;
|
||||||
|
uchar null_bit; // Bit used to test null bit
|
||||||
|
|
||||||
Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,uint null_bit_arg,
|
Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,uchar null_bit_arg,
|
||||||
utype unireg_check_arg, const char *field_name_arg,
|
utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg);
|
struct st_table *table_arg);
|
||||||
virtual ~Field() {}
|
virtual ~Field() {}
|
||||||
@@ -77,7 +78,7 @@ public:
|
|||||||
virtual enum_field_types real_type() const { return type(); }
|
virtual enum_field_types real_type() const { return type(); }
|
||||||
inline int cmp(const char *str) { return cmp(ptr,str); }
|
inline int cmp(const char *str) { return cmp(ptr,str); }
|
||||||
virtual int cmp(const char *,const char *)=0;
|
virtual int cmp(const char *,const char *)=0;
|
||||||
virtual int cmp_binary(const char *a,const char *b, ulong max_length=~0L)
|
virtual int cmp_binary(const char *a,const char *b, uint32 max_length=~0L)
|
||||||
{ return memcmp(a,b,pack_length()); }
|
{ return memcmp(a,b,pack_length()); }
|
||||||
virtual int cmp_offset(uint row_offset)
|
virtual int cmp_offset(uint row_offset)
|
||||||
{ return memcmp(ptr,ptr+row_offset,pack_length()); }
|
{ return memcmp(ptr,ptr+row_offset,pack_length()); }
|
||||||
@@ -101,16 +102,16 @@ public:
|
|||||||
inline void set_null(int row_offset=0)
|
inline void set_null(int row_offset=0)
|
||||||
{ if (null_ptr) null_ptr[row_offset]|= null_bit; }
|
{ if (null_ptr) null_ptr[row_offset]|= null_bit; }
|
||||||
inline void set_notnull(int row_offset=0)
|
inline void set_notnull(int row_offset=0)
|
||||||
{ if (null_ptr) null_ptr[row_offset]&= ~null_bit; }
|
{ if (null_ptr) null_ptr[row_offset]&= (uchar) ~null_bit; }
|
||||||
inline bool maybe_null(void) { return null_ptr != 0 || table->maybe_null; }
|
inline bool maybe_null(void) { return null_ptr != 0 || table->maybe_null; }
|
||||||
inline bool real_maybe_null(void) { return null_ptr != 0; }
|
inline bool real_maybe_null(void) { return null_ptr != 0; }
|
||||||
virtual void make_field(Send_field *)=0;
|
virtual void make_field(Send_field *)=0;
|
||||||
virtual void sort_string(char *buff,uint length)=0;
|
virtual void sort_string(char *buff,uint length)=0;
|
||||||
virtual bool optimize_range();
|
virtual bool optimize_range();
|
||||||
virtual bool store_for_compare() { return 0; }
|
virtual bool store_for_compare() { return 0; }
|
||||||
inline Field *new_field(struct st_table *new_table)
|
Field *new_field(MEM_ROOT *root, struct st_table *new_table)
|
||||||
{
|
{
|
||||||
Field *tmp= (Field*) sql_memdup((char*) this,size_of());
|
Field *tmp= (Field*) memdup_root(root,(char*) this,size_of());
|
||||||
if (tmp)
|
if (tmp)
|
||||||
{
|
{
|
||||||
tmp->table=new_table;
|
tmp->table=new_table;
|
||||||
@@ -121,7 +122,7 @@ public:
|
|||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
inline void move_field(char *ptr_arg,uchar *null_ptr_arg,uint null_bit_arg)
|
inline void move_field(char *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg)
|
||||||
{
|
{
|
||||||
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
|
ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg;
|
||||||
}
|
}
|
||||||
@@ -157,7 +158,7 @@ public:
|
|||||||
bool send(THD *thd, String *packet);
|
bool send(THD *thd, String *packet);
|
||||||
virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0)
|
virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0)
|
||||||
{
|
{
|
||||||
uint length=pack_length();
|
uint32 length=pack_length();
|
||||||
memcpy(to,from,length);
|
memcpy(to,from,length);
|
||||||
return to+length;
|
return to+length;
|
||||||
}
|
}
|
||||||
@@ -212,10 +213,10 @@ public:
|
|||||||
const uint8 dec;
|
const uint8 dec;
|
||||||
bool zerofill,unsigned_flag; // Purify cannot handle bit fields
|
bool zerofill,unsigned_flag; // Purify cannot handle bit fields
|
||||||
Field_num(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
|
Field_num(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg, utype unireg_check_arg,
|
uchar null_bit_arg, utype unireg_check_arg,
|
||||||
const char *field_name_arg,
|
const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
uint dec_arg,bool zero_arg,bool unsigned_arg)
|
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
|
||||||
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg),
|
unireg_check_arg, field_name_arg, table_arg),
|
||||||
dec(dec_arg),zerofill(zero_arg),unsigned_flag(unsigned_arg)
|
dec(dec_arg),zerofill(zero_arg),unsigned_flag(unsigned_arg)
|
||||||
@@ -230,7 +231,7 @@ public:
|
|||||||
void add_zerofill_and_unsigned(String &res) const;
|
void add_zerofill_and_unsigned(String &res) const;
|
||||||
friend class create_field;
|
friend class create_field;
|
||||||
void make_field(Send_field *);
|
void make_field(Send_field *);
|
||||||
uint decimals() const { return dec; }
|
uint decimals() const { return (uint) dec; }
|
||||||
uint size_of() const { return sizeof(*this); }
|
uint size_of() const { return sizeof(*this); }
|
||||||
bool eq_def(Field *field);
|
bool eq_def(Field *field);
|
||||||
};
|
};
|
||||||
@@ -239,7 +240,7 @@ public:
|
|||||||
class Field_str :public Field {
|
class Field_str :public Field {
|
||||||
public:
|
public:
|
||||||
Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
|
Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg, utype unireg_check_arg,
|
uchar null_bit_arg, utype unireg_check_arg,
|
||||||
const char *field_name_arg,
|
const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg)
|
||||||
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
@@ -256,10 +257,10 @@ public:
|
|||||||
class Field_decimal :public Field_num {
|
class Field_decimal :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_decimal(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_decimal(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
uint dec_arg,bool zero_arg,bool unsigned_arg)
|
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
|
||||||
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg,
|
unireg_check_arg, field_name_arg, table_arg,
|
||||||
dec_arg, zero_arg,unsigned_arg)
|
dec_arg, zero_arg,unsigned_arg)
|
||||||
@@ -285,7 +286,7 @@ public:
|
|||||||
class Field_tiny :public Field_num {
|
class Field_tiny :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_tiny(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_tiny(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
bool zero_arg, bool unsigned_arg)
|
bool zero_arg, bool unsigned_arg)
|
||||||
@@ -314,7 +315,7 @@ public:
|
|||||||
class Field_short :public Field_num {
|
class Field_short :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_short(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_short(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
bool zero_arg, bool unsigned_arg)
|
bool zero_arg, bool unsigned_arg)
|
||||||
@@ -343,7 +344,7 @@ public:
|
|||||||
class Field_medium :public Field_num {
|
class Field_medium :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_medium(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_medium(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
bool zero_arg, bool unsigned_arg)
|
bool zero_arg, bool unsigned_arg)
|
||||||
@@ -372,7 +373,7 @@ public:
|
|||||||
class Field_long :public Field_num {
|
class Field_long :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_long(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_long(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
bool zero_arg, bool unsigned_arg)
|
bool zero_arg, bool unsigned_arg)
|
||||||
@@ -407,7 +408,7 @@ public:
|
|||||||
class Field_longlong :public Field_num {
|
class Field_longlong :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_longlong(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_longlong(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
bool zero_arg, bool unsigned_arg)
|
bool zero_arg, bool unsigned_arg)
|
||||||
@@ -442,10 +443,10 @@ public:
|
|||||||
class Field_float :public Field_num {
|
class Field_float :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_float(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_float(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
uint dec_arg,bool zero_arg,bool unsigned_arg)
|
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
|
||||||
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg,
|
unireg_check_arg, field_name_arg, table_arg,
|
||||||
dec_arg, zero_arg,unsigned_arg)
|
dec_arg, zero_arg,unsigned_arg)
|
||||||
@@ -469,16 +470,16 @@ public:
|
|||||||
class Field_double :public Field_num {
|
class Field_double :public Field_num {
|
||||||
public:
|
public:
|
||||||
Field_double(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_double(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,
|
struct st_table *table_arg,
|
||||||
uint dec_arg,bool zero_arg,bool unsigned_arg)
|
uint8 dec_arg,bool zero_arg,bool unsigned_arg)
|
||||||
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field_num(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
unireg_check_arg, field_name_arg, table_arg,
|
unireg_check_arg, field_name_arg, table_arg,
|
||||||
dec_arg, zero_arg,unsigned_arg)
|
dec_arg, zero_arg,unsigned_arg)
|
||||||
{}
|
{}
|
||||||
Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
|
Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg, uint dec_arg)
|
struct st_table *table_arg, uint8 dec_arg)
|
||||||
:Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
|
:Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0,
|
||||||
NONE, field_name_arg, table_arg,dec_arg,0,0)
|
NONE, field_name_arg, table_arg,dec_arg,0,0)
|
||||||
{}
|
{}
|
||||||
@@ -567,7 +568,7 @@ public:
|
|||||||
class Field_year :public Field_tiny {
|
class Field_year :public Field_tiny {
|
||||||
public:
|
public:
|
||||||
Field_year(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_year(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg)
|
||||||
:Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
@@ -586,7 +587,7 @@ public:
|
|||||||
|
|
||||||
class Field_date :public Field_str {
|
class Field_date :public Field_str {
|
||||||
public:
|
public:
|
||||||
Field_date(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
|
Field_date(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg)
|
||||||
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
||||||
@@ -612,7 +613,7 @@ public:
|
|||||||
|
|
||||||
class Field_newdate :public Field_str {
|
class Field_newdate :public Field_str {
|
||||||
public:
|
public:
|
||||||
Field_newdate(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
|
Field_newdate(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg)
|
||||||
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
|
||||||
@@ -643,7 +644,7 @@ public:
|
|||||||
|
|
||||||
class Field_time :public Field_str {
|
class Field_time :public Field_str {
|
||||||
public:
|
public:
|
||||||
Field_time(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
|
Field_time(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg)
|
||||||
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
|
||||||
@@ -671,7 +672,7 @@ public:
|
|||||||
|
|
||||||
class Field_datetime :public Field_str {
|
class Field_datetime :public Field_str {
|
||||||
public:
|
public:
|
||||||
Field_datetime(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
|
Field_datetime(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg)
|
struct st_table *table_arg)
|
||||||
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
|
||||||
@@ -705,7 +706,7 @@ class Field_string :public Field_str {
|
|||||||
bool binary_flag;
|
bool binary_flag;
|
||||||
public:
|
public:
|
||||||
Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
|
Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,bool binary_arg)
|
struct st_table *table_arg,bool binary_arg)
|
||||||
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
@@ -760,7 +761,7 @@ class Field_varstring :public Field_str {
|
|||||||
bool binary_flag;
|
bool binary_flag;
|
||||||
public:
|
public:
|
||||||
Field_varstring(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
|
Field_varstring(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,bool binary_arg)
|
struct st_table *table_arg,bool binary_arg)
|
||||||
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
:Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
|
||||||
@@ -813,7 +814,7 @@ class Field_blob :public Field_str {
|
|||||||
String value; // For temporaries
|
String value; // For temporaries
|
||||||
bool binary_flag;
|
bool binary_flag;
|
||||||
public:
|
public:
|
||||||
Field_blob(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg,
|
Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,uint blob_pack_length,
|
struct st_table *table_arg,uint blob_pack_length,
|
||||||
bool binary_arg);
|
bool binary_arg);
|
||||||
@@ -837,21 +838,22 @@ public:
|
|||||||
longlong val_int(void);
|
longlong val_int(void);
|
||||||
String *val_str(String*,String *);
|
String *val_str(String*,String *);
|
||||||
int cmp(const char *,const char*);
|
int cmp(const char *,const char*);
|
||||||
int cmp(const char *a, ulong a_length, const char *b, ulong b_length);
|
int cmp(const char *a, uint32 a_length, const char *b, uint32 b_length);
|
||||||
int cmp_offset(uint offset);
|
int cmp_offset(uint offset);
|
||||||
int cmp_binary(const char *a,const char *b, ulong max_length=~0L);
|
int cmp_binary(const char *a,const char *b, uint32 max_length=~0L);
|
||||||
int cmp_binary_offset(uint row_offset);
|
int cmp_binary_offset(uint row_offset);
|
||||||
int key_cmp(const byte *,const byte*);
|
int key_cmp(const byte *,const byte*);
|
||||||
int key_cmp(const byte *str, uint length);
|
int key_cmp(const byte *str, uint length);
|
||||||
uint32 key_length() const { return 0; }
|
uint32 key_length() const { return 0; }
|
||||||
void sort_string(char *buff,uint length);
|
void sort_string(char *buff,uint length);
|
||||||
uint32 pack_length() const { return (uint32) (packlength+table->blob_ptr_size); }
|
uint32 pack_length() const
|
||||||
|
{ return (uint32) (packlength+table->blob_ptr_size); }
|
||||||
void reset(void) { bzero(ptr, packlength+sizeof(char*)); }
|
void reset(void) { bzero(ptr, packlength+sizeof(char*)); }
|
||||||
void reset_fields() { bzero((char*) &value,sizeof(value)); }
|
void reset_fields() { bzero((char*) &value,sizeof(value)); }
|
||||||
void store_length(ulong number);
|
void store_length(uint32 number);
|
||||||
inline ulong get_length(uint row_offset=0)
|
inline uint32 get_length(uint row_offset=0)
|
||||||
{ return get_length(ptr+row_offset); }
|
{ return get_length(ptr+row_offset); }
|
||||||
ulong get_length(const char *ptr);
|
uint32 get_length(const char *ptr);
|
||||||
bool binary() const { return binary_flag; }
|
bool binary() const { return binary_flag; }
|
||||||
inline void get_ptr(char **str)
|
inline void get_ptr(char **str)
|
||||||
{
|
{
|
||||||
@@ -862,7 +864,7 @@ public:
|
|||||||
memcpy(ptr,length,packlength);
|
memcpy(ptr,length,packlength);
|
||||||
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
|
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
|
||||||
}
|
}
|
||||||
inline void set_ptr(ulong length,char *data)
|
inline void set_ptr(uint32 length,char *data)
|
||||||
{
|
{
|
||||||
store_length(length);
|
store_length(length);
|
||||||
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
|
memcpy_fixed(ptr+packlength,&data,sizeof(char*));
|
||||||
@@ -902,7 +904,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
TYPELIB *typelib;
|
TYPELIB *typelib;
|
||||||
Field_enum(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_enum(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,uint packlength_arg,
|
struct st_table *table_arg,uint packlength_arg,
|
||||||
TYPELIB *typelib_arg)
|
TYPELIB *typelib_arg)
|
||||||
@@ -939,7 +941,7 @@ public:
|
|||||||
class Field_set :public Field_enum {
|
class Field_set :public Field_enum {
|
||||||
public:
|
public:
|
||||||
Field_set(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
Field_set(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
|
||||||
uint null_bit_arg,
|
uchar null_bit_arg,
|
||||||
enum utype unireg_check_arg, const char *field_name_arg,
|
enum utype unireg_check_arg, const char *field_name_arg,
|
||||||
struct st_table *table_arg,uint32 packlength_arg,
|
struct st_table *table_arg,uint32 packlength_arg,
|
||||||
TYPELIB *typelib_arg)
|
TYPELIB *typelib_arg)
|
||||||
@@ -1022,7 +1024,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
Field *make_field(char *ptr, uint32 field_length,
|
Field *make_field(char *ptr, uint32 field_length,
|
||||||
uchar *null_pos, uint null_bit,
|
uchar *null_pos, uchar null_bit,
|
||||||
uint pack_flag, Field::utype unireg_check,
|
uint pack_flag, Field::utype unireg_check,
|
||||||
TYPELIB *interval, const char *field_name,
|
TYPELIB *interval, const char *field_name,
|
||||||
struct st_table *table);
|
struct st_table *table);
|
||||||
@@ -1065,7 +1067,7 @@ bool test_if_int(const char *str,int length);
|
|||||||
#define f_is_zerofill(x) ((x) & FIELDFLAG_ZEROFILL)
|
#define f_is_zerofill(x) ((x) & FIELDFLAG_ZEROFILL)
|
||||||
#define f_is_packed(x) ((x) & FIELDFLAG_PACK)
|
#define f_is_packed(x) ((x) & FIELDFLAG_PACK)
|
||||||
#define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
|
#define f_packtype(x) (((x) >> FIELDFLAG_PACK_SHIFT) & 15)
|
||||||
#define f_decimals(x) (((x) >> FIELDFLAG_DEC_SHIFT) & FIELDFLAG_MAX_DEC)
|
#define f_decimals(x) ((uint8) (((x) >> FIELDFLAG_DEC_SHIFT) & FIELDFLAG_MAX_DEC))
|
||||||
#define f_is_alpha(x) (!f_is_num(x))
|
#define f_is_alpha(x) (!f_is_num(x))
|
||||||
#define f_is_binary(x) ((x) & FIELDFLAG_BINARY)
|
#define f_is_binary(x) ((x) & FIELDFLAG_BINARY)
|
||||||
#define f_is_enum(x) ((x) & FIELDFLAG_INTERVAL)
|
#define f_is_enum(x) ((x) & FIELDFLAG_INTERVAL)
|
||||||
|
@@ -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)
|
|||||||
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:
|
|||||||
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) {}
|
||||||
|
@@ -278,10 +278,9 @@ void Load_log_event::pack_info(String* packet)
|
|||||||
|
|
||||||
if (num_fields)
|
if (num_fields)
|
||||||
{
|
{
|
||||||
uint i;
|
|
||||||
const char* field = fields;
|
const char* field = fields;
|
||||||
tmp.append(" (");
|
tmp.append(" (");
|
||||||
for(i = 0; i < num_fields; i++)
|
for (uint i = 0; i < num_fields; i++)
|
||||||
{
|
{
|
||||||
if (i)
|
if (i)
|
||||||
tmp.append(" ,");
|
tmp.append(" ,");
|
||||||
@@ -971,12 +970,11 @@ char* sql_ex_info::init(char* buf,char* buf_end,bool use_new_format)
|
|||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
|
Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
|
||||||
const char* db_arg, const char* table_name_arg,
|
const char* db_arg, const char* table_name_arg,
|
||||||
List<Item>& fields_arg, enum enum_duplicates handle_dup):
|
List<Item>& fields_arg,
|
||||||
Log_event(thd),thread_id(thd->thread_id),
|
enum enum_duplicates handle_dup):
|
||||||
num_fields(0),fields(0),field_lens(0),field_block_len(0),
|
Log_event(thd), fields(0), field_lens(0),
|
||||||
table_name(table_name_arg),
|
table_name(table_name_arg), db(db_arg), fname(ex->file_name),
|
||||||
db(db_arg),
|
thread_id(thd->thread_id), num_fields(0), field_block_len(0)
|
||||||
fname(ex->file_name)
|
|
||||||
{
|
{
|
||||||
time_t end_time;
|
time_t end_time;
|
||||||
time(&end_time);
|
time(&end_time);
|
||||||
@@ -1004,8 +1002,7 @@ Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
|
|||||||
|
|
||||||
sql_ex.empty_flags = 0;
|
sql_ex.empty_flags = 0;
|
||||||
|
|
||||||
switch(handle_dup)
|
switch(handle_dup) {
|
||||||
{
|
|
||||||
case DUP_IGNORE: sql_ex.opt_flags |= IGNORE_FLAG; break;
|
case DUP_IGNORE: sql_ex.opt_flags |= IGNORE_FLAG; break;
|
||||||
case DUP_REPLACE: sql_ex.opt_flags |= REPLACE_FLAG; break;
|
case DUP_REPLACE: sql_ex.opt_flags |= REPLACE_FLAG; break;
|
||||||
case DUP_ERROR: break;
|
case DUP_ERROR: break;
|
||||||
@@ -1048,9 +1045,8 @@ Load_log_event::Load_log_event(THD* thd, sql_exchange* ex,
|
|||||||
// constructed event
|
// constructed event
|
||||||
Load_log_event::Load_log_event(const char* buf, int event_len,
|
Load_log_event::Load_log_event(const char* buf, int event_len,
|
||||||
bool old_format):
|
bool old_format):
|
||||||
Log_event(buf, old_format),num_fields(0),fields(0),
|
Log_event(buf, old_format),fields(0),
|
||||||
field_lens(0),field_block_len(0),
|
field_lens(0), num_fields(0), field_block_len(0)
|
||||||
table_name(0),db(0),fname(0)
|
|
||||||
{
|
{
|
||||||
if (!event_len) // derived class, will call copy_log_event() itself
|
if (!event_len) // derived class, will call copy_log_event() itself
|
||||||
return;
|
return;
|
||||||
@@ -1551,8 +1547,10 @@ int Query_log_event::exec_event(struct st_master_info* mi)
|
|||||||
thd->net.last_error[0] = 0;
|
thd->net.last_error[0] = 0;
|
||||||
thd->slave_proxy_id = thread_id; // for temp tables
|
thd->slave_proxy_id = thread_id; // for temp tables
|
||||||
|
|
||||||
// sanity check to make sure the master did not get a really bad
|
/*
|
||||||
// error on the query
|
sanity check to make sure the master did not get a really bad
|
||||||
|
error on the query
|
||||||
|
*/
|
||||||
if (!check_expected_error(thd, (expected_error = error_code)))
|
if (!check_expected_error(thd, (expected_error = error_code)))
|
||||||
{
|
{
|
||||||
mysql_parse(thd, thd->query, q_len);
|
mysql_parse(thd, thd->query, q_len);
|
||||||
|
235
sql/log_event.h
235
sql/log_event.h
@@ -244,9 +244,6 @@ public:
|
|||||||
virtual bool is_valid() = 0;
|
virtual bool is_valid() = 0;
|
||||||
virtual bool get_cache_stmt() { return 0; }
|
virtual bool get_cache_stmt() { return 0; }
|
||||||
Log_event(const char* buf, bool old_format);
|
Log_event(const char* buf, bool old_format);
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Log_event(THD* thd_arg, uint16 flags_arg = 0);
|
|
||||||
#endif
|
|
||||||
virtual ~Log_event() { free_temp_buf();}
|
virtual ~Log_event() { free_temp_buf();}
|
||||||
void register_temp_buf(char* buf) { temp_buf = buf; }
|
void register_temp_buf(char* buf) { temp_buf = buf; }
|
||||||
void free_temp_buf()
|
void free_temp_buf()
|
||||||
@@ -261,25 +258,17 @@ public:
|
|||||||
virtual int get_data_body_offset() { return 0; }
|
virtual int get_data_body_offset() { return 0; }
|
||||||
int get_event_len() { return cached_event_len ? cached_event_len :
|
int get_event_len() { return cached_event_len ? cached_event_len :
|
||||||
(cached_event_len = LOG_EVENT_HEADER_LEN + get_data_size()); }
|
(cached_event_len = LOG_EVENT_HEADER_LEN + get_data_size()); }
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
virtual void print(FILE* file, bool short_form = 0, char* last_db = 0) = 0;
|
|
||||||
void print_timestamp(FILE* file, time_t *ts = 0);
|
|
||||||
void print_header(FILE* file);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
// if mutex is 0, the read will proceed without mutex
|
|
||||||
static Log_event* read_log_event(IO_CACHE* file,
|
|
||||||
pthread_mutex_t* log_lock,
|
|
||||||
bool old_format);
|
|
||||||
#else // avoid having to link mysqlbinlog against libpthread
|
|
||||||
static Log_event* read_log_event(IO_CACHE* file, bool old_format);
|
|
||||||
#endif
|
|
||||||
static Log_event* read_log_event(const char* buf, int event_len,
|
static Log_event* read_log_event(const char* buf, int event_len,
|
||||||
const char **error, bool old_format);
|
const char **error, bool old_format);
|
||||||
const char* get_type_str();
|
const char* get_type_str();
|
||||||
|
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
// if mutex is 0, the read will proceed without mutex
|
||||||
|
Log_event(THD* thd_arg, uint16 flags_arg = 0);
|
||||||
|
static Log_event* read_log_event(IO_CACHE* file,
|
||||||
|
pthread_mutex_t* log_lock,
|
||||||
|
bool old_format);
|
||||||
static int read_log_event(IO_CACHE* file, String* packet,
|
static int read_log_event(IO_CACHE* file, String* packet,
|
||||||
pthread_mutex_t* log_lock);
|
pthread_mutex_t* log_lock);
|
||||||
void set_log_seq(THD* thd, MYSQL_LOG* log);
|
void set_log_seq(THD* thd, MYSQL_LOG* log);
|
||||||
@@ -291,6 +280,13 @@ public:
|
|||||||
{
|
{
|
||||||
return thd ? thd->db : 0;
|
return thd ? thd->db : 0;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
// avoid having to link mysqlbinlog against libpthread
|
||||||
|
static Log_event* read_log_event(IO_CACHE* file, bool old_format);
|
||||||
|
|
||||||
|
virtual void print(FILE* file, bool short_form = 0, char* last_db = 0) = 0;
|
||||||
|
void print_timestamp(FILE* file, time_t *ts = 0);
|
||||||
|
void print_header(FILE* file);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -303,13 +299,16 @@ protected:
|
|||||||
public:
|
public:
|
||||||
const char* query;
|
const char* query;
|
||||||
const char* db;
|
const char* db;
|
||||||
uint32 q_len; // if we already know the length of the query string
|
/*
|
||||||
// we pass it here, so we would not have to call strlen()
|
If we already know the length of the query string
|
||||||
// otherwise, set it to 0, in which case, we compute it with strlen()
|
we pass it here, so we would not have to call strlen()
|
||||||
|
otherwise, set it to 0, in which case, we compute it with strlen()
|
||||||
|
*/
|
||||||
|
uint32 q_len;
|
||||||
uint32 db_len;
|
uint32 db_len;
|
||||||
uint16 error_code;
|
uint16 error_code;
|
||||||
ulong thread_id;
|
ulong thread_id;
|
||||||
#if !defined(MYSQL_CLIENT)
|
#ifndef MYSQL_CLIENT
|
||||||
bool cache_stmt;
|
bool cache_stmt;
|
||||||
|
|
||||||
Query_log_event(THD* thd_arg, const char* query_arg,
|
Query_log_event(THD* thd_arg, const char* query_arg,
|
||||||
@@ -318,6 +317,8 @@ public:
|
|||||||
void pack_info(String* packet);
|
void pack_info(String* packet);
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
bool get_cache_stmt() { return cache_stmt; }
|
bool get_cache_stmt() { return cache_stmt; }
|
||||||
|
#else
|
||||||
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Query_log_event(const char* buf, int event_len, bool old_format);
|
Query_log_event(const char* buf, int event_len, bool old_format);
|
||||||
@@ -340,9 +341,6 @@ public:
|
|||||||
+ 2 // error_code
|
+ 2 // error_code
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Slave_log_event: public Log_event
|
class Slave_log_event: public Log_event
|
||||||
@@ -352,24 +350,22 @@ protected:
|
|||||||
void init_from_mem_pool(int data_size);
|
void init_from_mem_pool(int data_size);
|
||||||
public:
|
public:
|
||||||
char* master_host;
|
char* master_host;
|
||||||
int master_host_len;
|
|
||||||
uint16 master_port;
|
|
||||||
char* master_log;
|
char* master_log;
|
||||||
int master_log_len;
|
|
||||||
ulonglong master_pos;
|
ulonglong master_pos;
|
||||||
|
int master_host_len;
|
||||||
#ifndef MYSQL_CLIENT
|
int master_log_len;
|
||||||
Slave_log_event(THD* thd_arg, struct st_master_info* mi);
|
uint16 master_port;
|
||||||
void pack_info(String* packet);
|
|
||||||
int exec_event(struct st_master_info* mi);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Slave_log_event(const char* buf, int event_len);
|
Slave_log_event(const char* buf, int event_len);
|
||||||
~Slave_log_event();
|
~Slave_log_event();
|
||||||
int get_data_size();
|
int get_data_size();
|
||||||
bool is_valid() { return master_host != 0; }
|
bool is_valid() { return master_host != 0; }
|
||||||
Log_event_type get_type_code() { return SLAVE_EVENT; }
|
Log_event_type get_type_code() { return SLAVE_EVENT; }
|
||||||
#ifdef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Slave_log_event(THD* thd_arg, struct st_master_info* mi);
|
||||||
|
void pack_info(String* packet);
|
||||||
|
int exec_event(struct st_master_info* mi);
|
||||||
|
#else
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
int write_data(IO_CACHE* file );
|
int write_data(IO_CACHE* file );
|
||||||
@@ -382,22 +378,21 @@ protected:
|
|||||||
int copy_log_event(const char *buf, ulong event_len, bool old_format);
|
int copy_log_event(const char *buf, ulong event_len, bool old_format);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
const char* fields;
|
||||||
|
const uchar* field_lens;
|
||||||
|
const char* table_name;
|
||||||
|
const char* db;
|
||||||
|
const char* fname;
|
||||||
ulong thread_id;
|
ulong thread_id;
|
||||||
uint32 table_name_len;
|
uint32 table_name_len;
|
||||||
uint32 db_len;
|
uint32 db_len;
|
||||||
uint32 fname_len;
|
uint32 fname_len;
|
||||||
uint32 num_fields;
|
uint32 num_fields;
|
||||||
const char* fields;
|
|
||||||
const uchar* field_lens;
|
|
||||||
uint32 field_block_len;
|
uint32 field_block_len;
|
||||||
|
|
||||||
const char* table_name;
|
|
||||||
const char* db;
|
|
||||||
const char* fname;
|
|
||||||
uint32 skip_lines;
|
uint32 skip_lines;
|
||||||
sql_ex_info sql_ex;
|
sql_ex_info sql_ex;
|
||||||
|
|
||||||
#if !defined(MYSQL_CLIENT)
|
#ifndef MYSQL_CLIENT
|
||||||
String field_lens_buf;
|
String field_lens_buf;
|
||||||
String fields_buf;
|
String fields_buf;
|
||||||
|
|
||||||
@@ -412,6 +407,8 @@ public:
|
|||||||
return exec_event(thd->slave_net,mi);
|
return exec_event(thd->slave_net,mi);
|
||||||
}
|
}
|
||||||
int exec_event(NET* net, struct st_master_info* mi);
|
int exec_event(NET* net, struct st_master_info* mi);
|
||||||
|
#else
|
||||||
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Load_log_event(const char* buf, int event_len, bool old_format);
|
Load_log_event(const char* buf, int event_len, bool old_format);
|
||||||
@@ -434,9 +431,6 @@ public:
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
int get_data_body_offset() { return LOAD_EVENT_OVERHEAD; }
|
int get_data_body_offset() { return LOAD_EVENT_OVERHEAD; }
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char server_version[SERVER_VERSION_LENGTH];
|
extern char server_version[SERVER_VERSION_LENGTH];
|
||||||
@@ -447,13 +441,7 @@ public:
|
|||||||
uint32 created;
|
uint32 created;
|
||||||
uint16 binlog_version;
|
uint16 binlog_version;
|
||||||
char server_version[ST_SERVER_VER_LEN];
|
char server_version[ST_SERVER_VER_LEN];
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Start_log_event() :Log_event((THD*)0),binlog_version(BINLOG_VERSION)
|
|
||||||
{
|
|
||||||
created = (uint32) when;
|
|
||||||
memcpy(server_version, ::server_version, ST_SERVER_VER_LEN);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
Start_log_event(const char* buf, bool old_format);
|
Start_log_event(const char* buf, bool old_format);
|
||||||
~Start_log_event() {}
|
~Start_log_event() {}
|
||||||
Log_event_type get_type_code() { return START_EVENT;}
|
Log_event_type get_type_code() { return START_EVENT;}
|
||||||
@@ -464,10 +452,14 @@ public:
|
|||||||
return START_HEADER_LEN;
|
return START_HEADER_LEN;
|
||||||
}
|
}
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Start_log_event() :Log_event((THD*)0),binlog_version(BINLOG_VERSION)
|
||||||
|
{
|
||||||
|
created = (uint32) when;
|
||||||
|
memcpy(server_version, ::server_version, ST_SERVER_VER_LEN);
|
||||||
|
}
|
||||||
void pack_info(String* packet);
|
void pack_info(String* packet);
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
#endif
|
#else
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -477,11 +469,7 @@ class Intvar_log_event: public Log_event
|
|||||||
public:
|
public:
|
||||||
ulonglong val;
|
ulonglong val;
|
||||||
uchar type;
|
uchar type;
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
|
|
||||||
:Log_event(thd_arg),val(val_arg),type(type_arg)
|
|
||||||
{}
|
|
||||||
#endif
|
|
||||||
Intvar_log_event(const char* buf, bool old_format);
|
Intvar_log_event(const char* buf, bool old_format);
|
||||||
~Intvar_log_event() {}
|
~Intvar_log_event() {}
|
||||||
Log_event_type get_type_code() { return INTVAR_EVENT;}
|
Log_event_type get_type_code() { return INTVAR_EVENT;}
|
||||||
@@ -490,11 +478,12 @@ public:
|
|||||||
int write_data(IO_CACHE* file);
|
int write_data(IO_CACHE* file);
|
||||||
bool is_valid() { return 1; }
|
bool is_valid() { return 1; }
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Intvar_log_event(THD* thd_arg,uchar type_arg, ulonglong val_arg)
|
||||||
|
:Log_event(thd_arg),val(val_arg),type(type_arg)
|
||||||
|
{}
|
||||||
void pack_info(String* packet);
|
void pack_info(String* packet);
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
#endif
|
#else
|
||||||
|
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@@ -502,10 +491,6 @@ public:
|
|||||||
class Stop_log_event: public Log_event
|
class Stop_log_event: public Log_event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Stop_log_event() :Log_event((THD*)0)
|
|
||||||
{}
|
|
||||||
#endif
|
|
||||||
Stop_log_event(const char* buf, bool old_format):Log_event(buf,
|
Stop_log_event(const char* buf, bool old_format):Log_event(buf,
|
||||||
old_format)
|
old_format)
|
||||||
{
|
{
|
||||||
@@ -513,11 +498,11 @@ public:
|
|||||||
~Stop_log_event() {}
|
~Stop_log_event() {}
|
||||||
Log_event_type get_type_code() { return STOP_EVENT;}
|
Log_event_type get_type_code() { return STOP_EVENT;}
|
||||||
bool is_valid() { return 1; }
|
bool is_valid() { return 1; }
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
|
||||||
#endif
|
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Stop_log_event() :Log_event((THD*)0) {}
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
|
#else
|
||||||
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -525,19 +510,10 @@ class Rotate_log_event: public Log_event
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
const char* new_log_ident;
|
const char* new_log_ident;
|
||||||
uchar ident_len;
|
|
||||||
ulonglong pos;
|
ulonglong pos;
|
||||||
|
uint8 ident_len;
|
||||||
bool alloced;
|
bool alloced;
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Rotate_log_event(THD* thd_arg, const char* new_log_ident_arg,
|
|
||||||
uint ident_len_arg = 0,ulonglong pos_arg = 4) :
|
|
||||||
Log_event(thd_arg),
|
|
||||||
new_log_ident(new_log_ident_arg),
|
|
||||||
ident_len(ident_len_arg ? ident_len_arg :
|
|
||||||
(uint) strlen(new_log_ident_arg)), pos(pos_arg),
|
|
||||||
alloced(0)
|
|
||||||
{}
|
|
||||||
#endif
|
|
||||||
Rotate_log_event(const char* buf, int event_len, bool old_format);
|
Rotate_log_event(const char* buf, int event_len, bool old_format);
|
||||||
~Rotate_log_event()
|
~Rotate_log_event()
|
||||||
{
|
{
|
||||||
@@ -548,35 +524,38 @@ public:
|
|||||||
int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
|
int get_data_size() { return ident_len + ROTATE_HEADER_LEN;}
|
||||||
bool is_valid() { return new_log_ident != 0; }
|
bool is_valid() { return new_log_ident != 0; }
|
||||||
int write_data(IO_CACHE* file);
|
int write_data(IO_CACHE* file);
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
|
||||||
#endif
|
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Rotate_log_event(THD* thd_arg, const char* new_log_ident_arg,
|
||||||
|
uint8 ident_len_arg = 0,ulonglong pos_arg = 4) :
|
||||||
|
Log_event(thd_arg), new_log_ident(new_log_ident_arg),
|
||||||
|
pos(pos_arg),
|
||||||
|
ident_len(ident_len_arg ? ident_len_arg :
|
||||||
|
(uint8) strlen(new_log_ident_arg)),
|
||||||
|
alloced(0)
|
||||||
|
{}
|
||||||
void pack_info(String* packet);
|
void pack_info(String* packet);
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
|
#else
|
||||||
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* the classes below are for the new LOAD DATA INFILE logging */
|
/* the classes below are for the new LOAD DATA INFILE logging */
|
||||||
|
|
||||||
class Create_file_log_event: public Load_log_event
|
class Create_file_log_event: public Load_log_event
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
// pretend we are Load event, so we can write out just
|
/*
|
||||||
// our Load part - used on the slave when writing event out to
|
Pretend we are Load event, so we can write out just
|
||||||
// SQL_LOAD-*.info file
|
our Load part - used on the slave when writing event out to
|
||||||
|
SQL_LOAD-*.info file
|
||||||
|
*/
|
||||||
bool fake_base;
|
bool fake_base;
|
||||||
public:
|
public:
|
||||||
char* block;
|
char* block;
|
||||||
uint block_len;
|
uint block_len;
|
||||||
uint file_id;
|
uint file_id;
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
|
|
||||||
const char* table_name_arg,
|
|
||||||
List<Item>& fields_arg,
|
|
||||||
enum enum_duplicates handle_dup,
|
|
||||||
char* block_arg, uint block_len_arg);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Create_file_log_event(const char* buf, int event_len);
|
Create_file_log_event(const char* buf, int event_len);
|
||||||
~Create_file_log_event()
|
~Create_file_log_event()
|
||||||
@@ -586,26 +565,40 @@ public:
|
|||||||
{
|
{
|
||||||
return fake_base ? Load_log_event::get_type_code() : CREATE_FILE_EVENT;
|
return fake_base ? Load_log_event::get_type_code() : CREATE_FILE_EVENT;
|
||||||
}
|
}
|
||||||
int get_data_size() { return fake_base ? Load_log_event::get_data_size() :
|
int get_data_size()
|
||||||
|
{
|
||||||
|
return (fake_base ? Load_log_event::get_data_size() :
|
||||||
Load_log_event::get_data_size() +
|
Load_log_event::get_data_size() +
|
||||||
4 + 1 + block_len;}
|
4 + 1 + block_len);
|
||||||
int get_data_body_offset() { return fake_base ? LOAD_EVENT_OVERHEAD:
|
}
|
||||||
LOAD_EVENT_OVERHEAD + CREATE_FILE_HEADER_LEN; }
|
int get_data_body_offset()
|
||||||
|
{
|
||||||
|
return (fake_base ? LOAD_EVENT_OVERHEAD:
|
||||||
|
LOAD_EVENT_OVERHEAD + CREATE_FILE_HEADER_LEN);
|
||||||
|
}
|
||||||
bool is_valid() { return block != 0; }
|
bool is_valid() { return block != 0; }
|
||||||
int write_data_header(IO_CACHE* file);
|
int write_data_header(IO_CACHE* file);
|
||||||
int write_data_body(IO_CACHE* file);
|
int write_data_body(IO_CACHE* file);
|
||||||
int write_base(IO_CACHE* file); // cut out Create_file extentions and
|
/*
|
||||||
// write it as Load event - used on the slave
|
Cut out Create_file extentions and write it as Load event - used on the
|
||||||
|
slave.
|
||||||
|
*/
|
||||||
|
int write_base(IO_CACHE* file);
|
||||||
|
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
|
||||||
#endif
|
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg,
|
||||||
|
const char* table_name_arg,
|
||||||
|
List<Item>& fields_arg,
|
||||||
|
enum enum_duplicates handle_dup,
|
||||||
|
char* block_arg, uint block_len_arg);
|
||||||
void pack_info(String* packet);
|
void pack_info(String* packet);
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
|
#else
|
||||||
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Append_block_log_event: public Log_event
|
class Append_block_log_event: public Log_event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -613,12 +606,6 @@ public:
|
|||||||
uint block_len;
|
uint block_len;
|
||||||
uint file_id;
|
uint file_id;
|
||||||
|
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Append_block_log_event(THD* thd, char* block_arg,
|
|
||||||
uint block_len_arg);
|
|
||||||
int exec_event(struct st_master_info* mi);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Append_block_log_event(const char* buf, int event_len);
|
Append_block_log_event(const char* buf, int event_len);
|
||||||
~Append_block_log_event()
|
~Append_block_log_event()
|
||||||
{
|
{
|
||||||
@@ -628,23 +615,22 @@ public:
|
|||||||
bool is_valid() { return block != 0; }
|
bool is_valid() { return block != 0; }
|
||||||
int write_data(IO_CACHE* file);
|
int write_data(IO_CACHE* file);
|
||||||
|
|
||||||
#ifdef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Append_block_log_event(THD* thd, char* block_arg,
|
||||||
|
uint block_len_arg);
|
||||||
|
int exec_event(struct st_master_info* mi);
|
||||||
|
void pack_info(String* packet);
|
||||||
|
#else
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
void pack_info(String* packet);
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Delete_file_log_event: public Log_event
|
class Delete_file_log_event: public Log_event
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
uint file_id;
|
uint file_id;
|
||||||
|
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Delete_file_log_event(THD* thd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Delete_file_log_event(const char* buf, int event_len);
|
Delete_file_log_event(const char* buf, int event_len);
|
||||||
~Delete_file_log_event()
|
~Delete_file_log_event()
|
||||||
{
|
{
|
||||||
@@ -654,12 +640,12 @@ public:
|
|||||||
bool is_valid() { return file_id != 0; }
|
bool is_valid() { return file_id != 0; }
|
||||||
int write_data(IO_CACHE* file);
|
int write_data(IO_CACHE* file);
|
||||||
|
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
|
||||||
#endif
|
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Delete_file_log_event(THD* thd);
|
||||||
void pack_info(String* packet);
|
void pack_info(String* packet);
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
|
#else
|
||||||
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -668,10 +654,6 @@ class Execute_load_log_event: public Log_event
|
|||||||
public:
|
public:
|
||||||
uint file_id;
|
uint file_id;
|
||||||
|
|
||||||
#ifndef MYSQL_CLIENT
|
|
||||||
Execute_load_log_event(THD* thd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Execute_load_log_event(const char* buf, int event_len);
|
Execute_load_log_event(const char* buf, int event_len);
|
||||||
~Execute_load_log_event()
|
~Execute_load_log_event()
|
||||||
{
|
{
|
||||||
@@ -681,16 +663,13 @@ public:
|
|||||||
bool is_valid() { return file_id != 0; }
|
bool is_valid() { return file_id != 0; }
|
||||||
int write_data(IO_CACHE* file);
|
int write_data(IO_CACHE* file);
|
||||||
|
|
||||||
#ifdef MYSQL_CLIENT
|
|
||||||
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
|
||||||
#endif
|
|
||||||
#ifndef MYSQL_CLIENT
|
#ifndef MYSQL_CLIENT
|
||||||
|
Execute_load_log_event(THD* thd);
|
||||||
void pack_info(String* packet);
|
void pack_info(String* packet);
|
||||||
int exec_event(struct st_master_info* mi);
|
int exec_event(struct st_master_info* mi);
|
||||||
|
#else
|
||||||
|
void print(FILE* file, bool short_form = 0, char* last_db = 0);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif /* _LOG_EVENT_H */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -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,
|
|||||||
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[]= {
|
|||||||
{"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[]= {
|
|||||||
{"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},
|
||||||
@@ -3731,7 +3731,6 @@ static void get_options(int argc,char **argv)
|
|||||||
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)
|
|||||||
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);
|
|||||||
|
|
||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
}
|
}
|
||||||
/* 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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
}
|
}
|
||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
#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)
|
|||||||
{
|
{
|
||||||
#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 {
|
|||||||
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)
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
2084
sql/sql_cache.cc
2084
sql/sql_cache.cc
File diff suppressed because it is too large
Load Diff
106
sql/sql_cache.h
106
sql/sql_cache.h
@@ -82,14 +82,12 @@ struct Query_cache_block
|
|||||||
*pprev to join free blocks
|
*pprev to join free blocks
|
||||||
*prev to access to opposite side of list in cyclic sorted list
|
*prev to access to opposite side of list in cyclic sorted list
|
||||||
*/
|
*/
|
||||||
Query_cache_block
|
Query_cache_block *pnext,*pprev, // physical next/previous block
|
||||||
*pnext,*pprev, // physical next/previous block
|
|
||||||
*next,*prev; // logical next/previous block
|
*next,*prev; // logical next/previous block
|
||||||
block_type type;
|
block_type type;
|
||||||
TABLE_COUNTER_TYPE n_tables; // number of tables in query
|
TABLE_COUNTER_TYPE n_tables; // number of tables in query
|
||||||
|
|
||||||
inline my_bool is_free(void) { return type == FREE; }
|
inline my_bool is_free(void) { return type == FREE; }
|
||||||
|
|
||||||
void init(ulong length);
|
void init(ulong length);
|
||||||
void destroy();
|
void destroy();
|
||||||
inline uint headers_len();
|
inline uint headers_len();
|
||||||
@@ -132,9 +130,7 @@ struct Query_cache_query
|
|||||||
my_bool try_lock_writing();
|
my_bool try_lock_writing();
|
||||||
void unlock_writing();
|
void unlock_writing();
|
||||||
void unlock_reading();
|
void unlock_reading();
|
||||||
static byte * cache_key(const byte *record, uint *length,
|
static byte *cache_key(const byte *record, uint *length, my_bool not_used);
|
||||||
my_bool not_used);
|
|
||||||
static void free_cache(void *entry);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -159,20 +155,17 @@ struct Query_cache_table
|
|||||||
return (gptr)(((byte*)this)+
|
return (gptr)(((byte*)this)+
|
||||||
ALIGN_SIZE(sizeof(Query_cache_table)));
|
ALIGN_SIZE(sizeof(Query_cache_table)));
|
||||||
}
|
}
|
||||||
|
|
||||||
static byte * cache_key(const byte *record, uint *length,
|
|
||||||
my_bool not_used);
|
|
||||||
static void free_cache(void *entry);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Query_cache_result
|
struct Query_cache_result
|
||||||
{
|
{
|
||||||
Query_cache_block *query;
|
Query_cache_block *query;
|
||||||
|
|
||||||
inline gptr data(){return (gptr)(((byte*)this)+
|
inline gptr data()
|
||||||
ALIGN_SIZE(sizeof(Query_cache_result)));}
|
{
|
||||||
|
return (gptr)(((byte*) this)+
|
||||||
|
ALIGN_SIZE(sizeof(Query_cache_result)));
|
||||||
|
}
|
||||||
/* data_continue (if not whole packet contained by this block) */
|
/* data_continue (if not whole packet contained by this block) */
|
||||||
inline Query_cache_block *parent() { return query; }
|
inline Query_cache_block *parent() { return query; }
|
||||||
inline void parent (Query_cache_block *p) { query=p; }
|
inline void parent (Query_cache_block *p) { query=p; }
|
||||||
@@ -180,10 +173,14 @@ struct Query_cache_result
|
|||||||
|
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
byte *query_cache_query_get_key(const byte *record, uint *length,
|
||||||
|
my_bool not_used);
|
||||||
|
byte *query_cache_table_get_key(const byte *record, uint *length,
|
||||||
|
my_bool not_used);
|
||||||
void query_cache_insert(THD *thd, const char *packet, ulong length);
|
void query_cache_insert(THD *thd, const char *packet, ulong length);
|
||||||
void query_cache_end_of_result(THD *thd);
|
void query_cache_end_of_result(THD *thd);
|
||||||
void query_cache_abort(THD *thd);
|
void query_cache_abort(THD *thd);
|
||||||
void query_cache_invalidate_by_MyISAM_filename(char* filename);
|
void query_cache_invalidate_by_MyISAM_filename(const char* filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Query_cache_memory_bin
|
struct Query_cache_memory_bin
|
||||||
@@ -219,7 +216,23 @@ struct Query_cache_memory_bin_step
|
|||||||
|
|
||||||
class Query_cache
|
class Query_cache
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
/* Info */
|
||||||
|
ulong query_cache_size, query_cache_limit;
|
||||||
|
/* statistics */
|
||||||
|
ulong free_memory, queries_in_cache, hits, inserts, refused;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/*
|
||||||
|
The following mutex is locked when searching or changing global
|
||||||
|
query, tables lists or hashes. When we are operating inside the
|
||||||
|
query structure we locked an internal query block mutex.
|
||||||
|
LOCK SEQUENCE (to prevent deadlocks):
|
||||||
|
1. structure_guard_mutex
|
||||||
|
2. query block / table block / free block
|
||||||
|
3. results blocks (only when must become free).
|
||||||
|
*/
|
||||||
|
pthread_mutex_t structure_guard_mutex;
|
||||||
byte *cache; // cache memory
|
byte *cache; // cache memory
|
||||||
Query_cache_block *first_block; // physical location block list
|
Query_cache_block *first_block; // physical location block list
|
||||||
Query_cache_block *queries_blocks; // query list (LIFO)
|
Query_cache_block *queries_blocks; // query list (LIFO)
|
||||||
@@ -227,49 +240,31 @@ class Query_cache
|
|||||||
|
|
||||||
Query_cache_memory_bin *bins; // free block lists
|
Query_cache_memory_bin *bins; // free block lists
|
||||||
Query_cache_memory_bin_step *steps; // bins spacing info
|
Query_cache_memory_bin_step *steps; // bins spacing info
|
||||||
|
HASH queries, tables;
|
||||||
uint mem_bin_num, mem_bin_steps; // See at init_cache & find_bin
|
uint mem_bin_num, mem_bin_steps; // See at init_cache & find_bin
|
||||||
|
|
||||||
/* options */
|
|
||||||
ulong query_cache_size, query_cache_limit,
|
|
||||||
min_allocation_unit, min_result_data_size;
|
|
||||||
uint def_query_hash_size, def_table_hash_size;
|
|
||||||
|
|
||||||
/* statistics */
|
|
||||||
public:
|
|
||||||
ulong free_memory, queries_in_cache, hits, inserts, refused;
|
|
||||||
protected:
|
|
||||||
my_bool initialized;
|
my_bool initialized;
|
||||||
|
|
||||||
/*
|
/* options */
|
||||||
Locked when searched or changed global query or
|
ulong min_allocation_unit, min_result_data_size;
|
||||||
tables lists or hashes. When operate inside
|
uint def_query_hash_size, def_table_hash_size;
|
||||||
query structure locked own query block mutex
|
|
||||||
LOCK SEQUENCE (to prevent clinch):
|
|
||||||
1. structure_guard_mutex
|
|
||||||
2. query block / table block / free block
|
|
||||||
3. results blocks (only when must become free).
|
|
||||||
*/
|
|
||||||
pthread_mutex_t structure_guard_mutex;
|
|
||||||
|
|
||||||
HASH queries, tables;
|
|
||||||
|
|
||||||
/* Exclude/include from cyclic double linked list */
|
/* Exclude/include from cyclic double linked list */
|
||||||
static void double_linked_list_exclude(Query_cache_block *point,
|
static void double_linked_list_exclude(Query_cache_block *point,
|
||||||
Query_cache_block * &list_pointer);
|
Query_cache_block **list_pointer);
|
||||||
static void double_linked_list_simple_include(Query_cache_block *point,
|
static void double_linked_list_simple_include(Query_cache_block *point,
|
||||||
Query_cache_block *
|
Query_cache_block **
|
||||||
&list_pointer);
|
list_pointer);
|
||||||
static void double_linked_list_join(Query_cache_block *head_tail,
|
static void double_linked_list_join(Query_cache_block *head_tail,
|
||||||
Query_cache_block *tail_head);
|
Query_cache_block *tail_head);
|
||||||
|
|
||||||
/* Table key generation */
|
/* Table key generation */
|
||||||
static uint filename_2_table_key (char * key, char *filename);
|
static uint filename_2_table_key (char *key, const char *filename);
|
||||||
|
|
||||||
/* Following function work properly only when structure_guard_mutex locked */
|
/* The following functions require that structure_guard_mutex is locked */
|
||||||
void flush_cache();
|
void flush_cache();
|
||||||
my_bool free_old_query();
|
my_bool free_old_query();
|
||||||
void free_query(Query_cache_block *point);
|
void free_query(Query_cache_block *point);
|
||||||
my_bool allocate_data_chain(Query_cache_block * &result_block,
|
my_bool allocate_data_chain(Query_cache_block **result_block,
|
||||||
ulong data_len,
|
ulong data_len,
|
||||||
Query_cache_block *query_block);
|
Query_cache_block *query_block);
|
||||||
void invalidate_table(TABLE_LIST *table);
|
void invalidate_table(TABLE_LIST *table);
|
||||||
@@ -294,12 +289,12 @@ protected:
|
|||||||
ulong add_size);
|
ulong add_size);
|
||||||
void exclude_from_free_memory_list(Query_cache_block *free_block);
|
void exclude_from_free_memory_list(Query_cache_block *free_block);
|
||||||
void insert_into_free_memory_list(Query_cache_block *new_block);
|
void insert_into_free_memory_list(Query_cache_block *new_block);
|
||||||
my_bool move_by_type(byte * &border, Query_cache_block * &before,
|
my_bool move_by_type(byte **border, Query_cache_block **before,
|
||||||
ulong &gap, Query_cache_block * i);
|
ulong *gap, Query_cache_block *i);
|
||||||
uint find_bin(ulong size);
|
uint find_bin(ulong size);
|
||||||
void move_to_query_list_end(Query_cache_block *block);
|
void move_to_query_list_end(Query_cache_block *block);
|
||||||
void insert_into_free_memory_sorted_list(Query_cache_block *new_block,
|
void insert_into_free_memory_sorted_list(Query_cache_block *new_block,
|
||||||
Query_cache_block * &list);
|
Query_cache_block **list);
|
||||||
void pack_cache();
|
void pack_cache();
|
||||||
void relink(Query_cache_block *oblock,
|
void relink(Query_cache_block *oblock,
|
||||||
Query_cache_block *nblock,
|
Query_cache_block *nblock,
|
||||||
@@ -322,11 +317,10 @@ protected:
|
|||||||
Query_cache_block::block_type type,
|
Query_cache_block::block_type type,
|
||||||
TABLE_COUNTER_TYPE ntab = 0,
|
TABLE_COUNTER_TYPE ntab = 0,
|
||||||
my_bool under_guard=0);
|
my_bool under_guard=0);
|
||||||
my_bool append_result_data(Query_cache_block * &result,
|
my_bool append_result_data(Query_cache_block **result,
|
||||||
ulong data_len, gptr data,
|
ulong data_len, gptr data,
|
||||||
Query_cache_block * parent,
|
Query_cache_block *parent);
|
||||||
Query_cache_block * first_data_block);
|
my_bool write_result_data(Query_cache_block **result,
|
||||||
my_bool write_result_data(Query_cache_block * &result,
|
|
||||||
ulong data_len, gptr data,
|
ulong data_len, gptr data,
|
||||||
Query_cache_block *parent,
|
Query_cache_block *parent,
|
||||||
Query_cache_block::block_type
|
Query_cache_block::block_type
|
||||||
@@ -335,20 +329,18 @@ protected:
|
|||||||
ulong min,
|
ulong min,
|
||||||
my_bool under_guard=0);
|
my_bool under_guard=0);
|
||||||
/*
|
/*
|
||||||
If query is cachable return numder tables in query
|
If query is cacheable return number tables in query
|
||||||
(query without tables not cached)
|
(query without tables not cached)
|
||||||
*/
|
*/
|
||||||
TABLE_COUNTER_TYPE is_cachable(THD *thd, uint query_len, char *query,
|
TABLE_COUNTER_TYPE is_cacheable(THD *thd, uint32 query_len, char *query,
|
||||||
LEX *lex,
|
LEX *lex, TABLE_LIST *tables_used);
|
||||||
TABLE_LIST *tables_used);
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
Query_cache(ulong query_cache_limit = ULONG_MAX,
|
Query_cache(ulong query_cache_limit = ULONG_MAX,
|
||||||
ulong min_allocation_unit = QUERY_CACHE_MIN_ALLOCATION_UNIT,
|
ulong min_allocation_unit = QUERY_CACHE_MIN_ALLOCATION_UNIT,
|
||||||
ulong min_result_data_size = QUERY_CACHE_MIN_RESULT_DATA_SIZE,
|
ulong min_result_data_size = QUERY_CACHE_MIN_RESULT_DATA_SIZE,
|
||||||
uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
|
uint def_query_hash_size = QUERY_CACHE_DEF_QUERY_HASH_SIZE,
|
||||||
uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE
|
uint def_table_hash_size = QUERY_CACHE_DEF_TABLE_HASH_SIZE);
|
||||||
);
|
|
||||||
|
|
||||||
/* resize query cache (return real query size, 0 if disabled) */
|
/* resize query cache (return real query size, 0 if disabled) */
|
||||||
ulong resize(ulong query_cache_size);
|
ulong resize(ulong query_cache_size);
|
||||||
@@ -374,7 +366,7 @@ protected:
|
|||||||
void invalidate(char *db);
|
void invalidate(char *db);
|
||||||
|
|
||||||
/* Remove all queries that uses any of the listed following table */
|
/* Remove all queries that uses any of the listed following table */
|
||||||
void invalidate_by_MyISAM_filename(char * filename);
|
void invalidate_by_MyISAM_filename(const char *filename);
|
||||||
|
|
||||||
/* Remove all queries from cache */
|
/* Remove all queries from cache */
|
||||||
void flush();
|
void flush();
|
||||||
|
@@ -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:
|
|||||||
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:
|
|||||||
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)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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)
|
|||||||
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)
|
||||||
|
108
sql/sql_parse.cc
108
sql/sql_parse.cc
@@ -29,25 +29,42 @@
|
|||||||
#include <my_dir.h>
|
#include <my_dir.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_OPENSSL
|
||||||
|
/*
|
||||||
|
Without SSL the handshake consists of one packet. This packet
|
||||||
|
has both client capabilites and scrambled password.
|
||||||
|
With SSL the handshake might consist of two packets. If the first
|
||||||
|
packet (client capabilities) has CLIENT_SSL flag set, we have to
|
||||||
|
switch to SSL and read the second packet. The scrambled password
|
||||||
|
is in the second packet and client_capabilites field will be ignored.
|
||||||
|
Maybe it is better to accept flags other than CLIENT_SSL from the
|
||||||
|
second packet?
|
||||||
|
*/
|
||||||
|
#define SSL_HANDSHAKE_SIZE 2
|
||||||
|
#define NORMAL_HANDSHAKE_SIZE 6
|
||||||
|
#define MIN_HANDSHAKE_SIZE 2
|
||||||
|
#else
|
||||||
|
#define MIN_HANDSHAKE_SIZE 6
|
||||||
|
#endif /* HAVE_OPENSSL */
|
||||||
#define SCRAMBLE_LENGTH 8
|
#define SCRAMBLE_LENGTH 8
|
||||||
|
|
||||||
|
|
||||||
extern int yyparse(void);
|
extern int yyparse(void);
|
||||||
extern "C" pthread_mutex_t THR_LOCK_keycache;
|
extern "C" pthread_mutex_t THR_LOCK_keycache;
|
||||||
#ifdef SOLARIS
|
#ifdef SOLARIS
|
||||||
extern "C" int gethostname(char *name, int namelen);
|
extern "C" int gethostname(char *name, int namelen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int check_for_max_user_connections(const char *user, int u_length,
|
static int check_for_max_user_connections(const char *user, const char *host);
|
||||||
const char *host);
|
|
||||||
static void decrease_user_connections(const char *user, const char *host);
|
static void decrease_user_connections(const char *user, const char *host);
|
||||||
static bool check_db_used(THD *thd,TABLE_LIST *tables);
|
static bool check_db_used(THD *thd,TABLE_LIST *tables);
|
||||||
static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *tables);
|
static bool check_merge_table_access(THD *thd, char *db, TABLE_LIST *tables);
|
||||||
static bool check_dup(THD *thd,const char *db,const char *name,
|
static bool check_dup(const char *db, const char *name, TABLE_LIST *tables);
|
||||||
TABLE_LIST *tables);
|
|
||||||
static void mysql_init_query(THD *thd);
|
static void mysql_init_query(THD *thd);
|
||||||
static void remove_escape(char *name);
|
static void remove_escape(char *name);
|
||||||
static void refresh_status(void);
|
static void refresh_status(void);
|
||||||
static bool append_file_to_dir(char **filename_ptr, char *table_name);
|
static bool append_file_to_dir(THD *thd, char **filename_ptr,
|
||||||
|
char *table_name);
|
||||||
static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result);
|
static bool create_total_list(THD *thd, LEX *lex, TABLE_LIST **result);
|
||||||
|
|
||||||
const char *any_db="*any*"; // Special symbol for check_access
|
const char *any_db="*any*"; // Special symbol for check_access
|
||||||
@@ -160,7 +177,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
|
|||||||
db ? db : (char*) "");
|
db ? db : (char*) "");
|
||||||
thd->db_access=0;
|
thd->db_access=0;
|
||||||
if (max_user_connections &&
|
if (max_user_connections &&
|
||||||
check_for_max_user_connections(user, strlen(user), thd->host))
|
check_for_max_user_connections(user, thd->host))
|
||||||
return -1;
|
return -1;
|
||||||
if (db && db[0])
|
if (db && db[0])
|
||||||
{
|
{
|
||||||
@@ -210,8 +227,7 @@ void init_max_user_conn(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int check_for_max_user_connections(const char *user, int u_length,
|
static int check_for_max_user_connections(const char *user, const char *host)
|
||||||
const char *host)
|
|
||||||
{
|
{
|
||||||
int error=1;
|
int error=1;
|
||||||
uint temp_len;
|
uint temp_len;
|
||||||
@@ -363,49 +379,33 @@ check_connections(THD *thd)
|
|||||||
}
|
}
|
||||||
vio_keepalive(net->vio, TRUE);
|
vio_keepalive(net->vio, TRUE);
|
||||||
|
|
||||||
/* nasty, but any other way? */
|
ulong pkt_len=0;
|
||||||
uint pkt_len = 0;
|
|
||||||
{
|
{
|
||||||
/* buff[] needs to big enough to hold the server_version variable */
|
/* buff[] needs to big enough to hold the server_version variable */
|
||||||
char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH+32],*end;
|
char buff[SERVER_VERSION_LENGTH + SCRAMBLE_LENGTH+32],*end;
|
||||||
int client_flags = CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB;
|
int client_flags = CLIENT_LONG_FLAG | CLIENT_CONNECT_WITH_DB;
|
||||||
|
|
||||||
if (opt_using_transactions)
|
if (opt_using_transactions)
|
||||||
client_flags|=CLIENT_TRANSACTIONS;
|
client_flags|=CLIENT_TRANSACTIONS;
|
||||||
#ifdef HAVE_COMPRESS
|
#ifdef HAVE_COMPRESS
|
||||||
client_flags |= CLIENT_COMPRESS;
|
client_flags |= CLIENT_COMPRESS;
|
||||||
#endif /* HAVE_COMPRESS */
|
#endif /* HAVE_COMPRESS */
|
||||||
|
#ifdef HAVE_OPENSSL
|
||||||
|
if (ssl_acceptor_fd)
|
||||||
|
client_flags |= CLIENT_SSL; /* Wow, SSL is avalaible! */
|
||||||
|
#endif /* HAVE_OPENSSL */
|
||||||
|
|
||||||
end=strmov(buff,server_version)+1;
|
end=strnmov(buff,server_version,SERVER_VERSION_LENGTH)+1;
|
||||||
int4store((uchar*) end,thd->thread_id);
|
int4store((uchar*) end,thd->thread_id);
|
||||||
end+=4;
|
end+=4;
|
||||||
memcpy(end,thd->scramble,SCRAMBLE_LENGTH+1);
|
memcpy(end,thd->scramble,SCRAMBLE_LENGTH+1);
|
||||||
end+=SCRAMBLE_LENGTH +1;
|
end+=SCRAMBLE_LENGTH +1;
|
||||||
#ifdef HAVE_OPENSSL
|
|
||||||
if (ssl_acceptor_fd)
|
|
||||||
client_flags |= CLIENT_SSL; /* Wow, SSL is avalaible! */
|
|
||||||
/*
|
|
||||||
* Without SSL the handshake consists of one packet. This packet
|
|
||||||
* has both client capabilites and scrambled password.
|
|
||||||
* With SSL the handshake might consist of two packets. If the first
|
|
||||||
* packet (client capabilities) has CLIENT_SSL flag set, we have to
|
|
||||||
* switch to SSL and read the second packet. The scrambled password
|
|
||||||
* is in the second packet and client_capabilites field will be ignored.
|
|
||||||
* Maybe it is better to accept flags other than CLIENT_SSL from the
|
|
||||||
* second packet?
|
|
||||||
*/
|
|
||||||
#define SSL_HANDSHAKE_SIZE 2
|
|
||||||
#define NORMAL_HANDSHAKE_SIZE 6
|
|
||||||
#define MIN_HANDSHAKE_SIZE 2
|
|
||||||
|
|
||||||
#else
|
|
||||||
#define MIN_HANDSHAKE_SIZE 6
|
|
||||||
#endif /* HAVE_OPENSSL */
|
|
||||||
int2store(end,client_flags);
|
int2store(end,client_flags);
|
||||||
end[2]=MY_CHARSET_CURRENT;
|
end[2]=(char) MY_CHARSET_CURRENT;
|
||||||
int2store(end+3,thd->server_status);
|
int2store(end+3,thd->server_status);
|
||||||
bzero(end+5,13);
|
bzero(end+5,13);
|
||||||
end+=18;
|
end+=18;
|
||||||
if (net_write_command(net,protocol_version, buff,
|
if (net_write_command(net,(uchar) protocol_version, buff,
|
||||||
(uint) (end-buff)) ||
|
(uint) (end-buff)) ||
|
||||||
(pkt_len= my_net_read(net)) == packet_error ||
|
(pkt_len= my_net_read(net)) == packet_error ||
|
||||||
pkt_len < MIN_HANDSHAKE_SIZE)
|
pkt_len < MIN_HANDSHAKE_SIZE)
|
||||||
@@ -426,12 +426,9 @@ check_connections(THD *thd)
|
|||||||
if (thd->client_capabilities & CLIENT_IGNORE_SPACE)
|
if (thd->client_capabilities & CLIENT_IGNORE_SPACE)
|
||||||
thd->sql_mode|= MODE_IGNORE_SPACE;
|
thd->sql_mode|= MODE_IGNORE_SPACE;
|
||||||
#ifdef HAVE_OPENSSL
|
#ifdef HAVE_OPENSSL
|
||||||
DBUG_PRINT("info",
|
DBUG_PRINT("info", ("client capabilities: %d", thd->client_capabilities));
|
||||||
("pkt_len:%d, client capabilities: %d",
|
|
||||||
pkt_len, thd->client_capabilities) );
|
|
||||||
if (thd->client_capabilities & CLIENT_SSL)
|
if (thd->client_capabilities & CLIENT_SSL)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("Agreed to change IO layer to SSL") );
|
|
||||||
/* Do the SSL layering. */
|
/* Do the SSL layering. */
|
||||||
DBUG_PRINT("info", ("IO layer change in progress..."));
|
DBUG_PRINT("info", ("IO layer change in progress..."));
|
||||||
sslaccept(ssl_acceptor_fd, net->vio, thd->inactive_timeout);
|
sslaccept(ssl_acceptor_fd, net->vio, thd->inactive_timeout);
|
||||||
@@ -439,8 +436,8 @@ check_connections(THD *thd)
|
|||||||
if ((pkt_len=my_net_read(net)) == packet_error ||
|
if ((pkt_len=my_net_read(net)) == packet_error ||
|
||||||
pkt_len < NORMAL_HANDSHAKE_SIZE)
|
pkt_len < NORMAL_HANDSHAKE_SIZE)
|
||||||
{
|
{
|
||||||
DBUG_PRINT("info", ("pkt_len:%d", pkt_len));
|
DBUG_PRINT("error", ("Failed to read user information (pkt_len= %lu)",
|
||||||
DBUG_PRINT("error", ("Failed to read user information"));
|
pkt_len));
|
||||||
inc_host_errors(&thd->remote.sin_addr);
|
inc_host_errors(&thd->remote.sin_addr);
|
||||||
return(ER_HANDSHAKE_ERROR);
|
return(ER_HANDSHAKE_ERROR);
|
||||||
}
|
}
|
||||||
@@ -469,7 +466,7 @@ check_connections(THD *thd)
|
|||||||
if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
|
if ((thd->client_capabilities & CLIENT_TRANSACTIONS) &&
|
||||||
opt_using_transactions)
|
opt_using_transactions)
|
||||||
thd->net.return_status= &thd->server_status;
|
thd->net.return_status= &thd->server_status;
|
||||||
net->timeout=net_read_timeout;
|
net->timeout=(uint) net_read_timeout;
|
||||||
if (check_user(thd,COM_CONNECT, user, passwd, db, 1))
|
if (check_user(thd,COM_CONNECT, user, passwd, db, 1))
|
||||||
return (-1);
|
return (-1);
|
||||||
thd->password=test(passwd[0]);
|
thd->password=test(passwd[0]);
|
||||||
@@ -693,8 +690,8 @@ int mysql_table_dump(THD* thd, char* db, char* tbl_name, int fd)
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
thd->free_list = 0;
|
thd->free_list = 0;
|
||||||
|
thd->query_length=(uint) strlen(tbl_name);
|
||||||
thd->query = tbl_name;
|
thd->query = tbl_name;
|
||||||
thd->query_length=strlen(tbl_name);
|
|
||||||
if ((error = mysqld_dump_create_info(thd, table, -1)))
|
if ((error = mysqld_dump_create_info(thd, table, -1)))
|
||||||
{
|
{
|
||||||
my_error(ER_GET_ERRNO, MYF(0));
|
my_error(ER_GET_ERRNO, MYF(0));
|
||||||
@@ -715,7 +712,8 @@ err:
|
|||||||
bool do_command(THD *thd)
|
bool do_command(THD *thd)
|
||||||
{
|
{
|
||||||
char *packet;
|
char *packet;
|
||||||
uint old_timeout,packet_length;
|
uint old_timeout;
|
||||||
|
ulong packet_length;
|
||||||
NET *net;
|
NET *net;
|
||||||
enum enum_server_command command;
|
enum enum_server_command command;
|
||||||
DBUG_ENTER("do_command");
|
DBUG_ENTER("do_command");
|
||||||
@@ -725,7 +723,7 @@ bool do_command(THD *thd)
|
|||||||
|
|
||||||
packet=0;
|
packet=0;
|
||||||
old_timeout=net->timeout;
|
old_timeout=net->timeout;
|
||||||
net->timeout=thd->inactive_timeout; /* Wait max for 8 hours */
|
net->timeout=(uint) thd->inactive_timeout; // Wait max for 8 hours
|
||||||
net->last_error[0]=0; // Clear error message
|
net->last_error[0]=0; // Clear error message
|
||||||
net->last_errno=0;
|
net->last_errno=0;
|
||||||
|
|
||||||
@@ -745,7 +743,7 @@ bool do_command(THD *thd)
|
|||||||
command_name[command]));
|
command_name[command]));
|
||||||
}
|
}
|
||||||
net->timeout=old_timeout; // Timeout for writing
|
net->timeout=old_timeout; // Timeout for writing
|
||||||
DBUG_RETURN(dispatch_command(command,thd, packet+1, packet_length));
|
DBUG_RETURN(dispatch_command(command,thd, packet+1, (uint) packet_length));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -842,6 +840,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
|||||||
pos--;
|
pos--;
|
||||||
packet_length--;
|
packet_length--;
|
||||||
}
|
}
|
||||||
|
thd->query_length= packet_length;
|
||||||
if (!(thd->query= (char*) thd->memdup((gptr) (packet),packet_length+1)))
|
if (!(thd->query= (char*) thd->memdup((gptr) (packet),packet_length+1)))
|
||||||
break;
|
break;
|
||||||
thd->query[packet_length]=0;
|
thd->query[packet_length]=0;
|
||||||
@@ -872,8 +871,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
|
|||||||
}
|
}
|
||||||
thd->free_list=0;
|
thd->free_list=0;
|
||||||
table_list.name=table_list.real_name=thd->strdup(packet);
|
table_list.name=table_list.real_name=thd->strdup(packet);
|
||||||
thd->query=fields=thd->strdup(strend(packet)+1);
|
|
||||||
thd->query_length=strlen(thd->query);
|
thd->query_length=strlen(thd->query);
|
||||||
|
thd->query=fields=thd->strdup(strend(packet)+1);
|
||||||
mysql_log.write(thd,command,"%s %s",table_list.real_name,fields);
|
mysql_log.write(thd,command,"%s %s",table_list.real_name,fields);
|
||||||
remove_escape(table_list.real_name); // This can't have wildcards
|
remove_escape(table_list.real_name); // This can't have wildcards
|
||||||
|
|
||||||
@@ -1302,8 +1301,10 @@ mysql_execute_command(void)
|
|||||||
lex->create_info.data_file_name=lex->create_info.index_file_name=0;
|
lex->create_info.data_file_name=lex->create_info.index_file_name=0;
|
||||||
#else
|
#else
|
||||||
/* Fix names if symlinked tables */
|
/* Fix names if symlinked tables */
|
||||||
if (append_file_to_dir(&lex->create_info.data_file_name, tables->name) ||
|
if (append_file_to_dir(thd, &lex->create_info.data_file_name,
|
||||||
append_file_to_dir(&lex->create_info.index_file_name, tables->name))
|
tables->name) ||
|
||||||
|
append_file_to_dir(thd,&lex->create_info.index_file_name,
|
||||||
|
tables->name))
|
||||||
{
|
{
|
||||||
res=-1;
|
res=-1;
|
||||||
break;
|
break;
|
||||||
@@ -1314,7 +1315,7 @@ mysql_execute_command(void)
|
|||||||
select_result *result;
|
select_result *result;
|
||||||
|
|
||||||
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
|
if (!(lex->create_info.options & HA_LEX_CREATE_TMP_TABLE) &&
|
||||||
check_dup(thd,tables->db,tables->real_name,tables->next))
|
check_dup(tables->db, tables->real_name, tables->next))
|
||||||
{
|
{
|
||||||
net_printf(&thd->net,ER_INSERT_TABLE_USED,tables->real_name);
|
net_printf(&thd->net,ER_INSERT_TABLE_USED,tables->real_name);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
@@ -1618,7 +1619,7 @@ mysql_execute_command(void)
|
|||||||
if (thd->select_limit < select_lex->select_limit)
|
if (thd->select_limit < select_lex->select_limit)
|
||||||
thd->select_limit= HA_POS_ERROR; // No limit
|
thd->select_limit= HA_POS_ERROR; // No limit
|
||||||
|
|
||||||
if (check_dup(thd,tables->db,tables->real_name,tables->next))
|
if (check_dup(tables->db, tables->real_name, tables->next))
|
||||||
{
|
{
|
||||||
net_printf(&thd->net,ER_INSERT_TABLE_USED,tables->real_name);
|
net_printf(&thd->net,ER_INSERT_TABLE_USED,tables->real_name);
|
||||||
DBUG_VOID_RETURN;
|
DBUG_VOID_RETURN;
|
||||||
@@ -1906,7 +1907,7 @@ mysql_execute_command(void)
|
|||||||
}
|
}
|
||||||
case SQLCOM_SET_OPTION:
|
case SQLCOM_SET_OPTION:
|
||||||
{
|
{
|
||||||
uint org_options=thd->options;
|
ulong org_options=thd->options;
|
||||||
thd->options=select_lex->options;
|
thd->options=select_lex->options;
|
||||||
thd->update_lock_default= ((thd->options & OPTION_LOW_PRIORITY_UPDATES) ?
|
thd->update_lock_default= ((thd->options & OPTION_LOW_PRIORITY_UPDATES) ?
|
||||||
TL_WRITE_LOW_PRIORITY : TL_WRITE);
|
TL_WRITE_LOW_PRIORITY : TL_WRITE);
|
||||||
@@ -2975,8 +2976,7 @@ void add_join_natural(TABLE_LIST *a,TABLE_LIST *b)
|
|||||||
|
|
||||||
/* Check if name is used in table list */
|
/* Check if name is used in table list */
|
||||||
|
|
||||||
static bool check_dup(THD *thd,const char *db,const char *name,
|
static bool check_dup(const char *db, const char *name, TABLE_LIST *tables)
|
||||||
TABLE_LIST *tables)
|
|
||||||
{
|
{
|
||||||
for (; tables ; tables=tables->next)
|
for (; tables ; tables=tables->next)
|
||||||
if (!strcmp(name,tables->real_name) && !strcmp(db,tables->db))
|
if (!strcmp(name,tables->real_name) && !strcmp(db,tables->db))
|
||||||
@@ -3083,7 +3083,7 @@ static void refresh_status(void)
|
|||||||
|
|
||||||
/* If pointer is not a null pointer, append filename to it */
|
/* If pointer is not a null pointer, append filename to it */
|
||||||
|
|
||||||
static bool append_file_to_dir(char **filename_ptr, char *table_name)
|
static bool append_file_to_dir(THD *thd, char **filename_ptr, char *table_name)
|
||||||
{
|
{
|
||||||
char buff[FN_REFLEN],*ptr, *end;
|
char buff[FN_REFLEN],*ptr, *end;
|
||||||
if (!*filename_ptr)
|
if (!*filename_ptr)
|
||||||
@@ -3099,7 +3099,7 @@ static bool append_file_to_dir(char **filename_ptr, char *table_name)
|
|||||||
/* Fix is using unix filename format on dos */
|
/* Fix is using unix filename format on dos */
|
||||||
strmov(buff,*filename_ptr);
|
strmov(buff,*filename_ptr);
|
||||||
end=convert_dirname(buff, *filename_ptr, NullS);
|
end=convert_dirname(buff, *filename_ptr, NullS);
|
||||||
if (!(ptr=sql_alloc((uint) (end-buff)+strlen(table_name)+1)))
|
if (!(ptr=thd->alloc((uint) (end-buff)+(uint) strlen(table_name)+1)))
|
||||||
return 1; // End of memory
|
return 1; // End of memory
|
||||||
*filename_ptr=ptr;
|
*filename_ptr=ptr;
|
||||||
strxmov(ptr,buff,table_name,NullS);
|
strxmov(ptr,buff,table_name,NullS);
|
||||||
|
@@ -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,
|
|||||||
(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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
|
|
||||||
|
|
||||||
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)
|
|||||||
** 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,
|
|||||||
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,
|
|||||||
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,
|
|||||||
if (!arg->const_item())
|
if (!arg->const_item())
|
||||||
{
|
{
|
||||||
Field *new_field=
|
Field *new_field=
|
||||||
create_tmp_field(table,arg,arg->type(),©_func,tmp_from_field,
|
create_tmp_field(thd, table,arg,arg->type(),©_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,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Field *new_field=create_tmp_field(table,item,type,©_func,
|
Field *new_field=create_tmp_field(thd, table, item,type, ©_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,
|
|||||||
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)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
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)
|
|||||||
|
|
||||||
/* 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,
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
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
|
|||||||
{
|
{
|
||||||
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)
|
|||||||
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,
|
|||||||
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,
|
|||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user