Commit 12796f02 authored by unknown's avatar unknown

Doxygenized comments.

parent d43c15b0
...@@ -13,15 +13,16 @@ ...@@ -13,15 +13,16 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* /**
@file
This file is the net layer API for the MySQL client/server protocol, This file is the net layer API for the MySQL client/server protocol,
which is a tightly coupled, proprietary protocol owned by MySQL AB. which is a tightly coupled, proprietary protocol owned by MySQL AB.
@note
Any re-implementations of this protocol must also be under GPL Any re-implementations of this protocol must also be under GPL
unless one has got an license from MySQL AB stating otherwise. unless one has got an license from MySQL AB stating otherwise.
*/
/* Write and read of logical packets to/from socket.
Write and read of logical packets to/from socket
Writes are cached into net_buffer_length big packets. Writes are cached into net_buffer_length big packets.
Read packets are reallocated dynamicly when reading big packets. Read packets are reallocated dynamicly when reading big packets.
...@@ -111,7 +112,7 @@ extern void query_cache_insert(NET *net, const char *packet, ulong length); ...@@ -111,7 +112,7 @@ extern void query_cache_insert(NET *net, const char *packet, ulong length);
static my_bool net_write_buff(NET *net,const uchar *packet,ulong len); static my_bool net_write_buff(NET *net,const uchar *packet,ulong len);
/* Init with packet info */ /** Init with packet info. */
my_bool my_net_init(NET *net, Vio* vio) my_bool my_net_init(NET *net, Vio* vio)
{ {
...@@ -163,7 +164,7 @@ void net_end(NET *net) ...@@ -163,7 +164,7 @@ void net_end(NET *net)
} }
/* Realloc the packet buffer */ /** Realloc the packet buffer. */
my_bool net_realloc(NET *net, size_t length) my_bool net_realloc(NET *net, size_t length)
{ {
...@@ -201,19 +202,16 @@ my_bool net_realloc(NET *net, size_t length) ...@@ -201,19 +202,16 @@ my_bool net_realloc(NET *net, size_t length)
} }
/* /**
Check if there is any data to be read from the socket
SYNOPSIS
net_data_is_ready()
sd socket descriptor
DESCRIPTION
Check if there is any data to be read from the socket. Check if there is any data to be read from the socket.
RETURN VALUES @param sd socket descriptor
@retval
0 No data to read 0 No data to read
@retval
1 Data or EOF to read 1 Data or EOF to read
@retval
-1 Don't know if data is ready or not -1 Don't know if data is ready or not
*/ */
...@@ -258,16 +256,10 @@ static int net_data_is_ready(my_socket sd) ...@@ -258,16 +256,10 @@ static int net_data_is_ready(my_socket sd)
#endif /* EMBEDDED_LIBRARY */ #endif /* EMBEDDED_LIBRARY */
/* /**
Remove unwanted characters from connection Remove unwanted characters from connection
and check if disconnected and check if disconnected.
SYNOPSIS
net_clear()
net NET handler
clear_buffer If <> 0, then clear all data from communication buffer
DESCRIPTION
Read from socket until there is nothing more to read. Discard Read from socket until there is nothing more to read. Discard
what is read. what is read.
...@@ -278,6 +270,8 @@ static int net_data_is_ready(my_socket sd) ...@@ -278,6 +270,8 @@ static int net_data_is_ready(my_socket sd)
a FIN packet), then select() considers a socket "ready to read", a FIN packet), then select() considers a socket "ready to read",
in the sense that there's EOF to read, but read() returns 0. in the sense that there's EOF to read, but read() returns 0.
@param net NET handler
@param clear_buffer if <> 0, then clear all data from comm buff
*/ */
void net_clear(NET *net, my_bool clear_buffer) void net_clear(NET *net, my_bool clear_buffer)
...@@ -335,7 +329,7 @@ void net_clear(NET *net, my_bool clear_buffer) ...@@ -335,7 +329,7 @@ void net_clear(NET *net, my_bool clear_buffer)
} }
/* Flush write_buffer if not empty. */ /** Flush write_buffer if not empty. */
my_bool net_flush(NET *net) my_bool net_flush(NET *net)
{ {
...@@ -358,12 +352,13 @@ my_bool net_flush(NET *net) ...@@ -358,12 +352,13 @@ my_bool net_flush(NET *net)
** Write something to server/client buffer ** Write something to server/client buffer
*****************************************************************************/ *****************************************************************************/
/* /**
Write a logical packet with packet header Write a logical packet with packet header.
Format: Packet length (3 bytes), packet number(1 byte) Format: Packet length (3 bytes), packet number(1 byte)
When compression is used a 3 byte compression length is added When compression is used a 3 byte compression length is added
NOTE @note
If compression is used the original package is modified! If compression is used the original package is modified!
*/ */
...@@ -400,19 +395,9 @@ my_net_write(NET *net,const uchar *packet,size_t len) ...@@ -400,19 +395,9 @@ my_net_write(NET *net,const uchar *packet,size_t len)
return test(net_write_buff(net,packet,len)); return test(net_write_buff(net,packet,len));
} }
/* /**
Send a command to the server. Send a command to the server.
SYNOPSIS
net_write_command()
net NET handler
command Command in MySQL server (enum enum_server_command)
header Header to write after command
head_len Length of header
packet Query or parameter to query
len Length of packet
DESCRIPTION
The reason for having both header and packet is so that libmysql The reason for having both header and packet is so that libmysql
can easy add a header to a special command (like prepared statements) can easy add a header to a special command (like prepared statements)
without having to re-alloc the string. without having to re-alloc the string.
...@@ -420,11 +405,20 @@ my_net_write(NET *net,const uchar *packet,size_t len) ...@@ -420,11 +405,20 @@ my_net_write(NET *net,const uchar *packet,size_t len)
As the command is part of the first data packet, we have to do some data As the command is part of the first data packet, we have to do some data
juggling to put the command in there, without having to create a new juggling to put the command in there, without having to create a new
packet. packet.
This function will split big packets into sub-packets if needed. This function will split big packets into sub-packets if needed.
(Each sub packet can only be 2^24 bytes) (Each sub packet can only be 2^24 bytes)
RETURN VALUES @param net NET handler
@param command Command in MySQL server (enum enum_server_command)
@param header Header to write after command
@param head_len Length of header
@param packet Query or parameter to query
@param len Length of packet
@retval
0 ok 0 ok
@retval
1 error 1 error
*/ */
...@@ -468,16 +462,9 @@ net_write_command(NET *net,uchar command, ...@@ -468,16 +462,9 @@ net_write_command(NET *net,uchar command,
net_write_buff(net, packet, len) || net_flush(net))); net_write_buff(net, packet, len) || net_flush(net)));
} }
/* /**
Caching the data in a local buffer before sending it. Caching the data in a local buffer before sending it.
SYNOPSIS
net_write_buff()
net Network handler
packet Packet to send
len Length of packet
DESCRIPTION
Fill up net->buffer and send it to the client when full. Fill up net->buffer and send it to the client when full.
If the rest of the to-be-sent-packet is bigger than buffer, If the rest of the to-be-sent-packet is bigger than buffer,
...@@ -485,15 +472,19 @@ net_write_command(NET *net,uchar command, ...@@ -485,15 +472,19 @@ net_write_command(NET *net,uchar command,
If not, copy the rest of the data to the buffer and return without If not, copy the rest of the data to the buffer and return without
sending data. sending data.
NOTES @param net Network handler
The cached buffer can be sent as it is with 'net_flush()'. @param packet Packet to send
@param len Length of packet
@note
The cached buffer can be sent as it is with 'net_flush()'.
In this code we have to be careful to not send a packet longer than In this code we have to be careful to not send a packet longer than
MAX_PACKET_LENGTH to net_real_write() if we are using the compressed MAX_PACKET_LENGTH to net_real_write() if we are using the compressed
protocol as we store the length of the compressed packet in 3 bytes. protocol as we store the length of the compressed packet in 3 bytes.
RETURN @retval
0 ok 0 ok
@retval
1 1
*/ */
...@@ -547,9 +538,12 @@ net_write_buff(NET *net, const uchar *packet, ulong len) ...@@ -547,9 +538,12 @@ net_write_buff(NET *net, const uchar *packet, ulong len)
} }
/* /**
Read and write one packet using timeouts. Read and write one packet using timeouts.
If needed, the packet is compressed before sending. If needed, the packet is compressed before sending.
@todo
- TODO is it needed to set this variable if we have no socket
*/ */
int int
...@@ -726,18 +720,17 @@ static my_bool net_safe_read(NET *net, uchar *buff, size_t length, ...@@ -726,18 +720,17 @@ static my_bool net_safe_read(NET *net, uchar *buff, size_t length,
return 0; return 0;
} }
/* /**
Help function to clear the commuication buffer when we get a too big packet. Help function to clear the commuication buffer when we get a too big packet.
SYNOPSIS @param net Communication handle
my_net_skip_rest() @param remain Bytes to read
net Communication handle @param alarmed Parameter for thr_alarm()
remain Bytes to read @param alarm_buff Parameter for thr_alarm()
alarmed Parameter for thr_alarm()
alarm_buff Parameter for thr_alarm()
RETURN VALUES @retval
0 Was able to read the whole packet 0 Was able to read the whole packet
@retval
1 Got mailformed packet from client 1 Got mailformed packet from client
*/ */
...@@ -780,10 +773,13 @@ static my_bool my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed, ...@@ -780,10 +773,13 @@ static my_bool my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed,
#endif /* NO_ALARM */ #endif /* NO_ALARM */
/* /**
Reads one packet to net->buff + net->where_b Reads one packet to net->buff + net->where_b.
Returns length of packet. Long packets are handled by my_net_read(). Long packets are handled by my_net_read().
This function reallocates the net->buff buffer if necessary. This function reallocates the net->buff buffer if necessary.
@return
Returns length of packet.
*/ */
static ulong static ulong
...@@ -972,15 +968,18 @@ end: ...@@ -972,15 +968,18 @@ end:
} }
/* /**
Read a packet from the client/server and return it without the internal Read a packet from the client/server and return it without the internal
package header. package header.
If the packet is the first packet of a multi-packet packet If the packet is the first packet of a multi-packet packet
(which is indicated by the length of the packet = 0xffffff) then (which is indicated by the length of the packet = 0xffffff) then
all sub packets are read and concatenated. all sub packets are read and concatenated.
If the packet was compressed, its uncompressed and the length of the If the packet was compressed, its uncompressed and the length of the
uncompressed packet is returned. uncompressed packet is returned.
@return
The function returns the length of the found packet or packet_error. The function returns the length of the found packet or packet_error.
net->read_pos points to the read data. net->read_pos points to the read data.
*/ */
......
/* ------------------------------------------------------------------------ /**
Windows NT Service class library @file
@brief
Windows NT Service class library.
Copyright Abandoned 1998 Irena Pancirov - Irnet Snc Copyright Abandoned 1998 Irena Pancirov - Irnet Snc
This file is public domain and comes with NO WARRANTY of any kind This file is public domain and comes with NO WARRANTY of any kind
-------------------------------------------------------------------------- */ */
#include <windows.h> #include <windows.h>
#include <process.h> #include <process.h>
#include <stdio.h> #include <stdio.h>
...@@ -73,12 +77,13 @@ BOOL NTService::GetOS() ...@@ -73,12 +77,13 @@ BOOL NTService::GetOS()
} }
/* ------------------------------------------------------------------------ /**
Init() Registers the main service thread with the service manager Registers the main service thread with the service manager.
ServiceThread - pointer to the main programs entry function @param ServiceThread pointer to the main programs entry function
when the service is started when the service is started
-------------------------------------------------------------------------- */ */
long NTService::Init(LPCSTR szInternName,void *ServiceThread) long NTService::Init(LPCSTR szInternName,void *ServiceThread)
{ {
...@@ -99,13 +104,15 @@ long NTService::Init(LPCSTR szInternName,void *ServiceThread) ...@@ -99,13 +104,15 @@ long NTService::Init(LPCSTR szInternName,void *ServiceThread)
} }
/* ------------------------------------------------------------------------ /**
Install() - Installs the service with Service manager Installs the service with Service manager.
nError values: nError values:
0 success - 0 success
1 Can't open the Service manager - 1 Can't open the Service manager
2 Failed to create service - 2 Failed to create service.
-------------------------------------------------------------------------- */ */
BOOL NTService::Install(int startType, LPCSTR szInternName, BOOL NTService::Install(int startType, LPCSTR szInternName,
LPCSTR szDisplayName, LPCSTR szDisplayName,
...@@ -155,14 +162,16 @@ BOOL NTService::Install(int startType, LPCSTR szInternName, ...@@ -155,14 +162,16 @@ BOOL NTService::Install(int startType, LPCSTR szInternName,
} }
/* ------------------------------------------------------------------------ /**
Remove() - Removes the service Removes the service.
nError values: nError values:
0 success - 0 success
1 Can't open the Service manager - 1 Can't open the Service manager
2 Failed to locate service - 2 Failed to locate service
3 Failed to delete service - 3 Failed to delete service.
-------------------------------------------------------------------------- */ */
BOOL NTService::Remove(LPCSTR szInternName) BOOL NTService::Remove(LPCSTR szInternName)
{ {
...@@ -199,10 +208,10 @@ BOOL NTService::Remove(LPCSTR szInternName) ...@@ -199,10 +208,10 @@ BOOL NTService::Remove(LPCSTR szInternName)
return ret_value; return ret_value;
} }
/* ------------------------------------------------------------------------ /**
Stop() - this function should be called before the app. exits to stop this function should be called before the app. exits to stop
the service the service
-------------------------------------------------------------------------- */ */
void NTService::Stop(void) void NTService::Stop(void)
{ {
SetStatus(SERVICE_STOP_PENDING,NO_ERROR, 0, 1, 60000); SetStatus(SERVICE_STOP_PENDING,NO_ERROR, 0, 1, 60000);
...@@ -210,10 +219,11 @@ void NTService::Stop(void) ...@@ -210,10 +219,11 @@ void NTService::Stop(void)
SetStatus(SERVICE_STOPPED, NO_ERROR, 0, 1, 1000); SetStatus(SERVICE_STOPPED, NO_ERROR, 0, 1, 1000);
} }
/* ------------------------------------------------------------------------ /**
ServiceMain() - This is the function that is called from the This is the function that is called from the
service manager to start the service service manager to start the service.
-------------------------------------------------------------------------- */ */
void NTService::ServiceMain(DWORD argc, LPTSTR *argv) void NTService::ServiceMain(DWORD argc, LPTSTR *argv)
{ {
...@@ -264,9 +274,9 @@ error: ...@@ -264,9 +274,9 @@ error:
return; return;
} }
/* ------------------------------------------------------------------------ /**
StartService() - starts the appliaction thread starts the appliaction thread.
-------------------------------------------------------------------------- */ */
BOOL NTService::StartService() BOOL NTService::StartService()
{ {
......
...@@ -14,7 +14,9 @@ ...@@ -14,7 +14,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* /**
@file
Optimising of MIN(), MAX() and COUNT(*) queries without 'group by' clause Optimising of MIN(), MAX() and COUNT(*) queries without 'group by' clause
by replacing the aggregate expression with a constant. by replacing the aggregate expression with a constant.
...@@ -22,6 +24,7 @@ ...@@ -22,6 +24,7 @@
types of queries are optimised (assuming the table handler supports types of queries are optimised (assuming the table handler supports
the required methods) the required methods)
@verbatim
SELECT COUNT(*) FROM t1[,t2,t3,...] SELECT COUNT(*) FROM t1[,t2,t3,...]
SELECT MIN(b) FROM t1 WHERE a=const SELECT MIN(b) FROM t1 WHERE a=const
SELECT MAX(c) FROM t1 WHERE a=const AND b=const SELECT MAX(c) FROM t1 WHERE a=const AND b=const
...@@ -29,6 +32,7 @@ ...@@ -29,6 +32,7 @@
SELECT MIN(b) FROM t1 WHERE a=const AND b>const SELECT MIN(b) FROM t1 WHERE a=const AND b>const
SELECT MIN(b) FROM t1 WHERE a=const AND b BETWEEN const AND const SELECT MIN(b) FROM t1 WHERE a=const AND b BETWEEN const AND const
SELECT MAX(b) FROM t1 WHERE a=const AND b BETWEEN const AND const SELECT MAX(b) FROM t1 WHERE a=const AND b BETWEEN const AND const
@endverbatim
Instead of '<' one can use '<=', '>', '>=' and '=' as well. Instead of '<' one can use '<=', '>', '>=' and '=' as well.
Instead of 'a=const' the condition 'a IS NULL' can be used. Instead of 'a=const' the condition 'a IS NULL' can be used.
...@@ -36,10 +40,11 @@ ...@@ -36,10 +40,11 @@
If all selected fields are replaced then we will also remove all If all selected fields are replaced then we will also remove all
involved tables and return the answer without any join. Thus, the involved tables and return the answer without any join. Thus, the
following query will be replaced with a row of two constants: following query will be replaced with a row of two constants:
@verbatim
SELECT MAX(b), MIN(d) FROM t1,t2 SELECT MAX(b), MIN(d) FROM t1,t2
WHERE a=const AND b<const AND d>const WHERE a=const AND b<const AND d>const
@endverbatim
(assuming a index for column d of table t2 is defined) (assuming a index for column d of table t2 is defined)
*/ */
#include "mysql_priv.h" #include "mysql_priv.h"
...@@ -83,25 +88,25 @@ static ulonglong get_exact_record_count(TABLE_LIST *tables) ...@@ -83,25 +88,25 @@ static ulonglong get_exact_record_count(TABLE_LIST *tables)
} }
/* /**
Substitutes constants for some COUNT(), MIN() and MAX() functions. Substitutes constants for some COUNT(), MIN() and MAX() functions.
SYNOPSIS @param tables list of leaves of join table tree
opt_sum_query() @param all_fields All fields to be returned
tables list of leaves of join table tree @param conds WHERE clause
all_fields All fields to be returned
conds WHERE clause
NOTE: @note
This function is only called for queries with sum functions and no This function is only called for queries with sum functions and no
GROUP BY part. GROUP BY part.
RETURN VALUES @retval
0 no errors 0 no errors
@retval
1 if all items were resolved 1 if all items were resolved
@retval
HA_ERR_KEY_NOT_FOUND on impossible conditions HA_ERR_KEY_NOT_FOUND on impossible conditions
OR an error number from my_base.h HA_ERR_... if a deadlock or a lock @retval
wait timeout happens, for example HA_ERR_... if a deadlock or a lock wait timeout happens, for example
*/ */
int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
...@@ -472,19 +477,18 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) ...@@ -472,19 +477,18 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
} }
/* /**
Test if the predicate compares a field with constants Test if the predicate compares a field with constants.
SYNOPSIS @param func_item Predicate item
simple_pred() @param[out] args Here we store the field followed by constants
func_item Predicate item @param[out] inv_order Is set to 1 if the predicate is of the form
args out: Here we store the field followed by constants
inv_order out: Is set to 1 if the predicate is of the form
'const op field' 'const op field'
RETURN @retval
0 func_item is a simple predicate: a field is compared with 0 func_item is a simple predicate: a field is compared with
constants constants
@retval
1 Otherwise 1 Otherwise
*/ */
...@@ -556,22 +560,9 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) ...@@ -556,22 +560,9 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order)
} }
/* /**
Check whether a condition matches a key to get {MAX|MIN}(field): Check whether a condition matches a key to get {MAX|MIN}(field):.
SYNOPSIS
matching_cond()
max_fl in: Set to 1 if we are optimising MAX()
ref in/out: Reference to the structure we store the key value
keyinfo in Reference to the key info
field_part in: Pointer to the key part for the field
cond in WHERE condition
key_part_used in/out: Map of matchings parts
range_fl in/out: Says whether including key will be used
prefix_len out: Length of common key part for the range
where MAX/MIN is searched for
DESCRIPTION
For the index specified by the keyinfo parameter, index that For the index specified by the keyinfo parameter, index that
contains field as its component (field_part), the function contains field as its component (field_part), the function
checks whether the condition cond is a conjunction and all its checks whether the condition cond is a conjunction and all its
...@@ -582,8 +573,20 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order) ...@@ -582,8 +573,20 @@ bool simple_pred(Item_func *func_item, Item **args, bool *inv_order)
- field {<|<=|>=|>|=} const or const {<|<=|>=|>|=} field - field {<|<=|>=|>|=} const or const {<|<=|>=|>|=} field
- field between const1 and const2 - field between const1 and const2
RETURN @param[in] max_fl Set to 1 if we are optimising MAX()
@param[in,out] ref Reference to the structure we store the key
value
@param[in] keyinfo Reference to the key info
@param[in] field_part Pointer to the key part for the field
@param[in] cond WHERE condition
@param[in,out] key_part_used Map of matchings parts
@param[in,out] range_fl Says whether including key will be used
@param[out] prefix_len Length of common key part for the range
where MAX/MIN is searched for
@retval
0 Index can't be used. 0 Index can't be used.
@retval
1 We can use index to get MIN/MAX value 1 We can use index to get MIN/MAX value
*/ */
...@@ -748,31 +751,21 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, ...@@ -748,31 +751,21 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
} }
/* /**
Check whether we can get value for {max|min}(field) by using a key. Check whether we can get value for {max|min}(field) by using a key.
SYNOPSIS If where-condition is not a conjunction of 0 or more conjuct the
find_key_for_maxmin()
max_fl in: 0 for MIN(field) / 1 for MAX(field)
ref in/out Reference to the structure we store the key value
field in: Field used inside MIN() / MAX()
cond in: WHERE condition
range_fl out: Bit flags for how to search if key is ok
prefix_len out: Length of prefix for the search range
DESCRIPTION
If where condition is not a conjunction of 0 or more conjuct the
function returns false, otherwise it checks whether there is an function returns false, otherwise it checks whether there is an
index including field as its k-th component/part such that: index including field as its k-th component/part such that:
1. for each previous component f_i there is one and only one conjunct -# for each previous component f_i there is one and only one conjunct
of the form: f_i= const_i or const_i= f_i or f_i is null of the form: f_i= const_i or const_i= f_i or f_i is null
2. references to field occur only in conjucts of the form: -# references to field occur only in conjucts of the form:
field {<|<=|>=|>|=} const or const {<|<=|>=|>|=} field or field {<|<=|>=|>|=} const or const {<|<=|>=|>|=} field or
field BETWEEN const1 AND const2 field BETWEEN const1 AND const2
3. all references to the columns from the same table as column field -# all references to the columns from the same table as column field
occur only in conjucts mentioned above. occur only in conjucts mentioned above.
4. each of k first components the index is not partial, i.e. is not -# each of k first components the index is not partial, i.e. is not
defined on a fixed length proper prefix of the field. defined on a fixed length proper prefix of the field.
If such an index exists the function through the ref parameter If such an index exists the function through the ref parameter
...@@ -782,16 +775,25 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, ...@@ -782,16 +775,25 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo,
(if we have a condition field = const, prefix_len contains the length (if we have a condition field = const, prefix_len contains the length
of the whole search key) of the whole search key)
NOTE @param[in] max_fl 0 for MIN(field) / 1 for MAX(field)
@param[in,out] ref Reference to the structure we store the key value
@param[in] field Field used inside MIN() / MAX()
@param[in] cond WHERE condition
@param[out] range_fl Bit flags for how to search if key is ok
@param[out] prefix_len Length of prefix for the search range
@note
This function may set table->key_read to 1, which must be reset after This function may set table->key_read to 1, which must be reset after
index is used! (This can only happen when function returns 1) index is used! (This can only happen when function returns 1)
RETURN @retval
0 Index can not be used to optimize MIN(field)/MAX(field) 0 Index can not be used to optimize MIN(field)/MAX(field)
1 Can use key to optimize MIN()/MAX() @retval
1 Can use key to optimize MIN()/MAX().
In this case ref, range_fl and prefix_len are updated In this case ref, range_fl and prefix_len are updated
*/ */
static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
Field* field, COND *cond, Field* field, COND *cond,
uint *range_fl, uint *prefix_len) uint *range_fl, uint *prefix_len)
...@@ -883,20 +885,19 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref, ...@@ -883,20 +885,19 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
} }
/* /**
Check whether found key is in range specified by conditions Check whether found key is in range specified by conditions.
SYNOPSIS @param[in] max_fl 0 for MIN(field) / 1 for MAX(field)
reckey_in_range() @param[in] ref Reference to the key value and info
max_fl in: 0 for MIN(field) / 1 for MAX(field) @param[in] field Field used the MIN/MAX expression
ref in: Reference to the key value and info @param[in] cond WHERE condition
field in: Field used the MIN/MAX expression @param[in] range_fl Says whether there is a condition to to be checked
cond in: WHERE condition @param[in] prefix_len Length of the constant part of the key
range_fl in: Says whether there is a condition to to be checked
prefix_len in: Length of the constant part of the key
RETURN @retval
0 ok 0 ok
@retval
1 WHERE was not true for the found row 1 WHERE was not true for the found row
*/ */
...@@ -911,16 +912,16 @@ static int reckey_in_range(bool max_fl, TABLE_REF *ref, Field* field, ...@@ -911,16 +912,16 @@ static int reckey_in_range(bool max_fl, TABLE_REF *ref, Field* field,
} }
/* /**
Check whether {MAX|MIN}(field) is in range specified by conditions Check whether {MAX|MIN}(field) is in range specified by conditions.
SYNOPSIS
maxmin_in_range()
max_fl in: 0 for MIN(field) / 1 for MAX(field)
field in: Field used the MIN/MAX expression
cond in: WHERE condition
RETURN @param[in] max_fl 0 for MIN(field) / 1 for MAX(field)
@param[in] field Field used the MIN/MAX expression
@param[in] cond WHERE condition
@retval
0 ok 0 ok
@retval
1 WHERE was not true for the found row 1 WHERE was not true for the found row
*/ */
......
This diff is collapsed.
...@@ -68,10 +68,13 @@ my_decimal *Item_proc_real::val_decimal(my_decimal *decimal_value) ...@@ -68,10 +68,13 @@ my_decimal *Item_proc_real::val_decimal(my_decimal *decimal_value)
} }
/***************************************************************************** /**
** Setup handling of procedure Setup handling of procedure.
** Return 0 if everything is ok
*****************************************************************************/ @return
Return 0 if everything is ok
*/
Procedure * Procedure *
setup_procedure(THD *thd,ORDER *param,select_result *result, setup_procedure(THD *thd,ORDER *param,select_result *result,
......
...@@ -13,8 +13,10 @@ ...@@ -13,8 +13,10 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* /**
Low level functions for storing data to be send to the MySQL client @file
Low level functions for storing data to be send to the MySQL client.
The actual communction is handled by the net_xxx functions in net_serv.cc The actual communction is handled by the net_xxx functions in net_serv.cc
*/ */
...@@ -53,14 +55,15 @@ bool Protocol_binary::net_store_data(const uchar *from, size_t length) ...@@ -53,14 +55,15 @@ bool Protocol_binary::net_store_data(const uchar *from, size_t length)
} }
/* /**
Send a error string to client Send a error string to client.
Design note: Design note:
net_printf_error and net_send_error are low-level functions net_printf_error and net_send_error are low-level functions
that shall be used only when a new connection is being that shall be used only when a new connection is being
established or at server startup. established or at server startup.
For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's
critical that every error that can be intercepted is issued in one critical that every error that can be intercepted is issued in one
place only, my_message_sql. place only, my_message_sql.
...@@ -120,16 +123,19 @@ void net_send_error(THD *thd, uint sql_errno, const char *err) ...@@ -120,16 +123,19 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* /**
Write error package and flush to client Write error package and flush to client.
@note
It's a little too low level, but I don't want to use another buffer for It's a little too low level, but I don't want to use another buffer for
this this.
Design note: Design note:
net_printf_error and net_send_error are low-level functions net_printf_error and net_send_error are low-level functions
that shall be used only when a new connection is being that shall be used only when a new connection is being
established or at server startup. established or at server startup.
For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's For SIGNAL/RESIGNAL and GET DIAGNOSTICS functionality it's
critical that every error that can be intercepted is issued in one critical that every error that can be intercepted is issued in one
place only, my_message_sql. place only, my_message_sql.
...@@ -239,30 +245,27 @@ net_printf_error(THD *thd, uint errcode, ...) ...@@ -239,30 +245,27 @@ net_printf_error(THD *thd, uint errcode, ...)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
/* /**
Return ok to the client. Return ok to the client.
SYNOPSIS The ok packet has the following structure:
send_ok()
thd Thread handler - 0 : Marker (1 byte)
affected_rows Number of rows changed by statement - affected_rows : Stored in 1-9 bytes
id Auto_increment id for first row (if used) - id : Stored in 1-9 bytes
message Message to send to the client (Used by mysql_status) - server_status : Copy of thd->server_status; Can be used by client
to check if we are inside an transaction.
DESCRIPTION
The ok packet has the following structure
0 Marker (1 byte)
affected_rows Stored in 1-9 bytes
id Stored in 1-9 bytes
server_status Copy of thd->server_status; Can be used by client
to check if we are inside an transaction
New in 4.0 protocol New in 4.0 protocol
warning_count Stored in 2 bytes; New in 4.1 protocol - warning_count : Stored in 2 bytes; New in 4.1 protocol
message Stored as packed length (1-9 bytes) + message - message : Stored as packed length (1-9 bytes) + message.
Is not stored if no message Is not stored if no message.
If net->no_send_ok return without sending packet If net->no_send_ok return without sending packet.
@param thd Thread handler
@param affected_rows Number of rows changed by statement
@param id Auto_increment id for first row (if used)
@param message Message to send to the client (Used by mysql_status)
*/ */
#ifndef EMBEDDED_LIBRARY #ifndef EMBEDDED_LIBRARY
...@@ -319,26 +322,23 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) ...@@ -319,26 +322,23 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message)
static uchar eof_buff[1]= { (uchar) 254 }; /* Marker for end of fields */ static uchar eof_buff[1]= { (uchar) 254 }; /* Marker for end of fields */
/* /**
Send eof (= end of result set) to the client Send eof (= end of result set) to the client.
SYNOPSIS
send_eof()
thd Thread handler
no_flush Set to 1 if there will be more data to the client,
like in send_fields().
DESCRIPTION The eof packet has the following structure:
The eof packet has the following structure
254 Marker (1 byte) - 254 : Marker (1 byte)
warning_count Stored in 2 bytes; New in 4.1 protocol - warning_count : Stored in 2 bytes; New in 4.1 protocol
status_flag Stored in 2 bytes; - status_flag : Stored in 2 bytes;
For flags like SERVER_MORE_RESULTS_EXISTS For flags like SERVER_MORE_RESULTS_EXISTS.
Note that the warning count will not be sent if 'no_flush' is set as Note that the warning count will not be sent if 'no_flush' is set as
we don't want to report the warning count until all data is sent to the we don't want to report the warning count until all data is sent to the
client. client.
@param thd Thread handler
@param no_flush Set to 1 if there will be more data to the client,
like in send_fields().
*/ */
void void
...@@ -357,7 +357,7 @@ send_eof(THD *thd) ...@@ -357,7 +357,7 @@ send_eof(THD *thd)
} }
/* /**
Format EOF packet according to the current protocol and Format EOF packet according to the current protocol and
write it to the network output buffer. write it to the network output buffer.
*/ */
...@@ -388,14 +388,14 @@ static void write_eof_packet(THD *thd, NET *net) ...@@ -388,14 +388,14 @@ static void write_eof_packet(THD *thd, NET *net)
VOID(my_net_write(net, eof_buff, 1)); VOID(my_net_write(net, eof_buff, 1));
} }
/* /**
Please client to send scrambled_password in old format. Please client to send scrambled_password in old format.
SYNOPSYS
send_old_password_request()
thd thread handle
RETURN VALUE @param thd thread handle
@retval
0 ok 0 ok
@retval
!0 error !0 error
*/ */
...@@ -450,14 +450,15 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) ...@@ -450,14 +450,15 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
#endif /* EMBEDDED_LIBRARY */ #endif /* EMBEDDED_LIBRARY */
/* /**
Faster net_store_length when we know that length is less than 65536. Faster net_store_length when we know that length is less than 65536.
We keep a separate version for that range because it's widely used in We keep a separate version for that range because it's widely used in
libmysql. libmysql.
uint is used as agrument type because of MySQL type conventions: uint is used as agrument type because of MySQL type conventions:
uint for 0..65536 - uint for 0..65536
ulong for 0..4294967296 - ulong for 0..4294967296
ulonglong for bigger numbers. - ulonglong for bigger numbers.
*/ */
static uchar *net_store_length_fast(uchar *packet, uint length) static uchar *net_store_length_fast(uchar *packet, uint length)
...@@ -530,27 +531,26 @@ bool Protocol::flush() ...@@ -530,27 +531,26 @@ bool Protocol::flush()
#endif #endif
} }
/* #ifndef EMBEDDED_LIBRARY
Send name and type of result to client.
SYNOPSIS /**
send_fields() Send name and type of result to client.
THD Thread data object
list List of items to send to client
flag Bit mask with the following functions:
1 send number of rows
2 send default values
4 don't write eof packet
DESCRIPTION
Sum fields has table name empty and field_name. Sum fields has table name empty and field_name.
RETURN VALUES @param THD Thread data object
@param list List of items to send to client
@param flag Bit mask with the following functions:
- 1 send number of rows
- 2 send default values
- 4 don't write eof packet
@retval
0 ok 0 ok
1 Error (Note that in this case the error is not sent to the client) @retval
1 Error (Note that in this case the error is not sent to the
client)
*/ */
#ifndef EMBEDDED_LIBRARY
bool Protocol::send_fields(List<Item> *list, uint flags) bool Protocol::send_fields(List<Item> *list, uint flags)
{ {
List_iterator_fast<Item> it(*list); List_iterator_fast<Item> it(*list);
...@@ -704,18 +704,17 @@ bool Protocol::write() ...@@ -704,18 +704,17 @@ bool Protocol::write()
#endif /* EMBEDDED_LIBRARY */ #endif /* EMBEDDED_LIBRARY */
/* /**
Send \0 end terminated string Send \\0 end terminated string.
SYNOPSIS @param from NullS or \\0 terminated string
store()
from NullS or \0 terminated string
NOTES @note
In most cases one should use store(from, length) instead of this function In most cases one should use store(from, length) instead of this function
RETURN VALUES @retval
0 ok 0 ok
@retval
1 error 1 error
*/ */
...@@ -728,8 +727,8 @@ bool Protocol::store(const char *from, CHARSET_INFO *cs) ...@@ -728,8 +727,8 @@ bool Protocol::store(const char *from, CHARSET_INFO *cs)
} }
/* /**
Send a set of strings as one long string with ',' in between Send a set of strings as one long string with ',' in between.
*/ */
bool Protocol::store(I_List<i_string>* str_list) bool Protocol::store(I_List<i_string>* str_list)
...@@ -781,7 +780,7 @@ bool Protocol_text::store_null() ...@@ -781,7 +780,7 @@ bool Protocol_text::store_null()
#endif #endif
/* /**
Auxilary function to convert string to the given character set Auxilary function to convert string to the given character set
and store in network buffer. and store in network buffer.
*/ */
...@@ -957,13 +956,12 @@ bool Protocol_text::store(Field *field) ...@@ -957,13 +956,12 @@ bool Protocol_text::store(Field *field)
} }
/* /**
TODO: @todo
Second_part format ("%06") needs to change when Second_part format ("%06") needs to change when
we support 0-6 decimals for time. we support 0-6 decimals for time.
*/ */
bool Protocol_text::store(MYSQL_TIME *tm) bool Protocol_text::store(MYSQL_TIME *tm)
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
...@@ -1001,8 +999,8 @@ bool Protocol_text::store_date(MYSQL_TIME *tm) ...@@ -1001,8 +999,8 @@ bool Protocol_text::store_date(MYSQL_TIME *tm)
} }
/* /**
TODO: @todo
Second_part format ("%06") needs to change when Second_part format ("%06") needs to change when
we support 0-6 decimals for time. we support 0-6 decimals for time.
*/ */
......
...@@ -14,7 +14,12 @@ ...@@ -14,7 +14,12 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* Functions for easy reading of records, possible through a cache */ /**
@file
@brief
Functions for easy reading of records, possible through a cache
*/
#include "mysql_priv.h" #include "mysql_priv.h"
...@@ -31,25 +36,20 @@ static int rr_index_first(READ_RECORD *info); ...@@ -31,25 +36,20 @@ static int rr_index_first(READ_RECORD *info);
static int rr_index(READ_RECORD *info); static int rr_index(READ_RECORD *info);
/* /**
Initialize READ_RECORD structure to perform full index scan
SYNOPSIS
init_read_record_idx()
info READ_RECORD structure to initialize.
thd Thread handle
table Table to be accessed
print_error If true, call table->file->print_error() if an error
occurs (except for end-of-records error)
idx index to scan
DESCRIPTION
Initialize READ_RECORD structure to perform full index scan (in forward Initialize READ_RECORD structure to perform full index scan (in forward
direction) using read_record.read_record() interface. direction) using read_record.read_record() interface.
This function has been added at late stage and is used only by This function has been added at late stage and is used only by
UPDATE/DELETE. Other statements perform index scans using UPDATE/DELETE. Other statements perform index scans using
join_read_first/next functions. join_read_first/next functions.
@param info READ_RECORD structure to initialize.
@param thd Thread handle
@param table Table to be accessed
@param print_error If true, call table->file->print_error() if an error
occurs (except for end-of-records error)
@param idx index to scan
*/ */
void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table, void init_read_record_idx(READ_RECORD *info, THD *thd, TABLE *table,
...@@ -284,7 +284,7 @@ static int rr_handle_error(READ_RECORD *info, int error) ...@@ -284,7 +284,7 @@ static int rr_handle_error(READ_RECORD *info, int error)
} }
/* Read a record from head-database */ /** Read a record from head-database. */
static int rr_quick(READ_RECORD *info) static int rr_quick(READ_RECORD *info)
{ {
...@@ -306,20 +306,19 @@ static int rr_quick(READ_RECORD *info) ...@@ -306,20 +306,19 @@ static int rr_quick(READ_RECORD *info)
} }
/* /**
Reads first row in an index scan Reads first row in an index scan.
SYNOPSIS @param info Scan info
rr_index_first()
info Scan info
RETURN @retval
0 Ok 0 Ok
@retval
-1 End of records -1 End of records
@retval
1 Error 1 Error
*/ */
static int rr_index_first(READ_RECORD *info) static int rr_index_first(READ_RECORD *info)
{ {
int tmp= info->file->index_first(info->record); int tmp= info->file->index_first(info->record);
...@@ -330,24 +329,22 @@ static int rr_index_first(READ_RECORD *info) ...@@ -330,24 +329,22 @@ static int rr_index_first(READ_RECORD *info)
} }
/* /**
Reads index sequentially after first row Reads index sequentially after first row.
SYNOPSIS
rr_index()
info Scan info
DESCRIPTION
Read the next index record (in forward direction) and translate return Read the next index record (in forward direction) and translate return
value. value.
RETURN @param info Scan info
@retval
0 Ok 0 Ok
@retval
-1 End of records -1 End of records
@retval
1 Error 1 Error
*/ */
static int rr_index(READ_RECORD *info) static int rr_index(READ_RECORD *info)
{ {
int tmp= info->file->index_next(info->record); int tmp= info->file->index_next(info->record);
...@@ -401,22 +398,20 @@ static int rr_from_tempfile(READ_RECORD *info) ...@@ -401,22 +398,20 @@ static int rr_from_tempfile(READ_RECORD *info)
} /* rr_from_tempfile */ } /* rr_from_tempfile */
/* /**
Read a result set record from a temporary file after sorting Read a result set record from a temporary file after sorting.
SYNOPSIS
rr_unpack_from_tempfile()
info Reference to the context including record descriptors
DESCRIPTION
The function first reads the next sorted record from the temporary file. The function first reads the next sorted record from the temporary file.
into a buffer. If a success it calls a callback function that unpacks into a buffer. If a success it calls a callback function that unpacks
the fields values use in the result set from this buffer into their the fields values use in the result set from this buffer into their
positions in the regular record buffer. positions in the regular record buffer.
RETURN @param info Reference to the context including record descriptors
0 - Record successfully read.
-1 - There is no record to be read anymore. @retval
0 Record successfully read.
@retval
-1 There is no record to be read anymore.
*/ */
static int rr_unpack_from_tempfile(READ_RECORD *info) static int rr_unpack_from_tempfile(READ_RECORD *info)
...@@ -454,22 +449,20 @@ static int rr_from_pointers(READ_RECORD *info) ...@@ -454,22 +449,20 @@ static int rr_from_pointers(READ_RECORD *info)
return tmp; return tmp;
} }
/* /**
Read a result set record from a buffer after sorting Read a result set record from a buffer after sorting.
SYNOPSIS
rr_unpack_from_buffer()
info Reference to the context including record descriptors
DESCRIPTION
The function first reads the next sorted record from the sort buffer. The function first reads the next sorted record from the sort buffer.
If a success it calls a callback function that unpacks If a success it calls a callback function that unpacks
the fields values use in the result set from this buffer into their the fields values use in the result set from this buffer into their
positions in the regular record buffer. positions in the regular record buffer.
RETURN @param info Reference to the context including record descriptors
0 - Record successfully read.
-1 - There is no record to be read anymore. @retval
0 Record successfully read.
@retval
-1 There is no record to be read anymore.
*/ */
static int rr_unpack_from_buffer(READ_RECORD *info) static int rr_unpack_from_buffer(READ_RECORD *info)
......
...@@ -13,6 +13,16 @@ ...@@ -13,6 +13,16 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/**
@file
All of the functions defined in this file which are not used (the ones to
handle failsafe) are not used; their code has not been updated for more
than one year now so should be considered as BADLY BROKEN. Do not enable
it. The used functions (to handle LOAD DATA FROM MASTER, plus some small
functions like register_slave()) are working.
*/
#include "mysql_priv.h" #include "mysql_priv.h"
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
...@@ -144,11 +154,12 @@ void unregister_slave(THD* thd, bool only_mine, bool need_mutex) ...@@ -144,11 +154,12 @@ void unregister_slave(THD* thd, bool only_mine, bool need_mutex)
} }
/* /**
Register slave in 'slave_list' hash table Register slave in 'slave_list' hash table.
RETURN VALUES @return
0 ok 0 ok
@return
1 Error. Error message sent to client 1 Error. Error message sent to client
*/ */
...@@ -252,7 +263,8 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg) ...@@ -252,7 +263,8 @@ static int find_target_pos(LEX_MASTER_INFO *mi, IO_CACHE *log, char *errmsg)
/* Impossible */ /* Impossible */
} }
/* /**
@details
Before 4.0.15 we had a member of THD called log_pos, it was meant for Before 4.0.15 we had a member of THD called log_pos, it was meant for
failsafe replication code in repl_failsafe.cc which is disabled until failsafe replication code in repl_failsafe.cc which is disabled until
it is reworked. Event's log_pos used to be preserved through it is reworked. Event's log_pos used to be preserved through
...@@ -388,8 +400,8 @@ err: ...@@ -388,8 +400,8 @@ err:
} }
/* /**
Caller must delete result when done Caller must delete result when done.
*/ */
static Slave_log_event* find_slave_event(IO_CACHE* log, static Slave_log_event* find_slave_event(IO_CACHE* log,
...@@ -428,9 +440,11 @@ static Slave_log_event* find_slave_event(IO_CACHE* log, ...@@ -428,9 +440,11 @@ static Slave_log_event* find_slave_event(IO_CACHE* log,
return (Slave_log_event*)ev; return (Slave_log_event*)ev;
} }
/* /**
This function is broken now. See comment for translate_master(). This function is broken now.
*/
@seealso translate_master()
*/
bool show_new_master(THD* thd) bool show_new_master(THD* thd)
{ {
...@@ -466,20 +480,19 @@ bool show_new_master(THD* thd) ...@@ -466,20 +480,19 @@ bool show_new_master(THD* thd)
} }
} }
/* /**
Asks the master for the list of its other connected slaves. Asks the master for the list of its other connected slaves.
This is for failsafe replication: This is for failsafe replication:
in order for failsafe replication to work, the servers involved in in order for failsafe replication to work, the servers involved in
replication must know of each other. We accomplish this by having each replication must know of each other. We accomplish this by having each
slave report to the master how to reach it, and on connection, each slave report to the master how to reach it, and on connection, each
slave receives information about where the other slaves are. slave receives information about where the other slaves are.
SYNOPSIS @param mysql pre-existing connection to the master
update_slave_list() @param mi master info
mysql pre-existing connection to the master
mi master info
NOTES @note
mi is used only to give detailed error messages which include the mi is used only to give detailed error messages which include the
hostname/port of the master, the username used by the slave to connect to hostname/port of the master, the username used by the slave to connect to
the master. the master.
...@@ -487,10 +500,11 @@ bool show_new_master(THD* thd) ...@@ -487,10 +500,11 @@ bool show_new_master(THD* thd)
REPLICATION SLAVE privilege, it will pop in this function because REPLICATION SLAVE privilege, it will pop in this function because
SHOW SLAVE HOSTS will fail on the master. SHOW SLAVE HOSTS will fail on the master.
RETURN VALUES @retval
1 error 1 error
@retval
0 success 0 success
*/ */
int update_slave_list(MYSQL* mysql, Master_info* mi) int update_slave_list(MYSQL* mysql, Master_info* mi)
{ {
...@@ -754,11 +768,16 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db, ...@@ -754,11 +768,16 @@ static int fetch_db_tables(THD *thd, MYSQL *mysql, const char *db,
return 0; return 0;
} }
/* /**
Load all MyISAM tables from master to this slave. Load all MyISAM tables from master to this slave.
REQUIREMENTS REQUIREMENTS
- No active transaction (flush_relay_log_info would not work in this case) - No active transaction (flush_relay_log_info would not work in this case).
@todo
- add special option, not enabled
by default, to allow inclusion of mysql database into load
data from master
*/ */
bool load_master_data(THD* thd) bool load_master_data(THD* thd)
......
...@@ -13,9 +13,13 @@ ...@@ -13,9 +13,13 @@
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
/* /**
@file
@brief
Handling of MySQL SQL variables Handling of MySQL SQL variables
@details
To add a new variable, one has to do the following: To add a new variable, one has to do the following:
- Use one of the 'sys_var... classes from set_var.h or write a specific - Use one of the 'sys_var... classes from set_var.h or write a specific
...@@ -28,18 +32,19 @@ ...@@ -28,18 +32,19 @@
- Don't forget to initialize new fields in global_system_variables and - Don't forget to initialize new fields in global_system_variables and
max_system_variables! max_system_variables!
NOTES: @todo
- Be careful with var->save_result: sys_var::check() only updates Add full support for the variable character_set (for 4.1)
ulonglong_value; so other members of the union are garbage then; to use
them you must first assign a value to them (in specific ::check() for
example).
TODO:
- Add full support for the variable character_set (for 4.1)
- When updating myisam_delay_key_write, we should do a 'flush tables' @todo
When updating myisam_delay_key_write, we should do a 'flush tables'
of all MyISAM tables to ensure that they are reopen with the of all MyISAM tables to ensure that they are reopen with the
new attribute. new attribute.
@note
Be careful with var->save_result: sys_var::check() only updates
ulonglong_value; so other members of the union are garbage then; to use
them you must first assign a value to them (in specific ::check() for
example).
*/ */
#ifdef USE_PRAGMA_IMPLEMENTATION #ifdef USE_PRAGMA_IMPLEMENTATION
...@@ -819,9 +824,9 @@ static void sys_default_ftb_syntax(THD *thd, enum_var_type type) ...@@ -819,9 +824,9 @@ static void sys_default_ftb_syntax(THD *thd, enum_var_type type)
} }
/* /**
If one sets the LOW_PRIORIY UPDATES flag, we also must change the If one sets the LOW_PRIORIY UPDATES flag, we also must change the
used lock type used lock type.
*/ */
static void fix_low_priority_updates(THD *thd, enum_var_type type) static void fix_low_priority_updates(THD *thd, enum_var_type type)
...@@ -843,8 +848,8 @@ fix_myisam_max_sort_file_size(THD *thd, enum_var_type type) ...@@ -843,8 +848,8 @@ fix_myisam_max_sort_file_size(THD *thd, enum_var_type type)
(my_off_t) global_system_variables.myisam_max_sort_file_size; (my_off_t) global_system_variables.myisam_max_sort_file_size;
} }
/* /**
Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR Set the OPTION_BIG_SELECTS flag if max_join_size == HA_POS_ERROR.
*/ */
static void fix_max_join_size(THD *thd, enum_var_type type) static void fix_max_join_size(THD *thd, enum_var_type type)
...@@ -859,7 +864,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type) ...@@ -859,7 +864,7 @@ static void fix_max_join_size(THD *thd, enum_var_type type)
} }
/* /**
Can't change the 'next' tx_isolation while we are already in Can't change the 'next' tx_isolation while we are already in
a transaction a transaction
*/ */
...@@ -875,7 +880,7 @@ static int check_tx_isolation(THD *thd, set_var *var) ...@@ -875,7 +880,7 @@ static int check_tx_isolation(THD *thd, set_var *var)
/* /*
If one doesn't use the SESSION modifier, the isolation level If one doesn't use the SESSION modifier, the isolation level
is only active for the next command is only active for the next command.
*/ */
static void fix_tx_isolation(THD *thd, enum_var_type type) static void fix_tx_isolation(THD *thd, enum_var_type type)
{ {
...@@ -1447,9 +1452,12 @@ err: ...@@ -1447,9 +1452,12 @@ err:
} }
/* /**
Return an Item for a variable. Used with @@[global.]variable_name Return an Item for a variable.
If type is not given, return local value if exists, else global
Used with @@[global.]variable_name.
If type is not given, return local value if exists, else global.
*/ */
Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base) Item *sys_var::item(THD *thd, enum_var_type var_type, LEX_STRING *base)
...@@ -1611,7 +1619,7 @@ uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type, ...@@ -1611,7 +1619,7 @@ uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type,
} }
/* Update a date_time format variable based on given value */ /** Update a date_time format variable based on given value. */
void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type, void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type,
DATE_TIME_FORMAT *new_value) DATE_TIME_FORMAT *new_value)
...@@ -2028,6 +2036,12 @@ end: ...@@ -2028,6 +2036,12 @@ end:
} }
/**
@todo
Abort if some other thread is changing the key cache.
This should be changed so that we wait until the previous
assignment is done and then do the new assign
*/
bool sys_var_key_cache_long::update(THD *thd, set_var *var) bool sys_var_key_cache_long::update(THD *thd, set_var *var)
{ {
ulong tmp= (ulong) var->value->val_int(); ulong tmp= (ulong) var->value->val_int();
...@@ -2720,23 +2734,20 @@ static uchar *get_error_count(THD *thd) ...@@ -2720,23 +2734,20 @@ static uchar *get_error_count(THD *thd)
} }
/* /**
Get the tmpdir that was specified or chosen by default Get the tmpdir that was specified or chosen by default.
SYNOPSIS
get_tmpdir()
thd thread handle
DESCRIPTION
This is necessary because if the user does not specify a temporary This is necessary because if the user does not specify a temporary
directory via the command line, one is chosen based on the environment directory via the command line, one is chosen based on the environment
or system defaults. But we can't just always use mysql_tmpdir, because or system defaults. But we can't just always use mysql_tmpdir, because
that is actually a call to my_tmpdir() which cycles among possible that is actually a call to my_tmpdir() which cycles among possible
temporary directories. temporary directories.
RETURN VALUES @param thd thread handle
@retval
ptr pointer to NUL-terminated string ptr pointer to NUL-terminated string
*/ */
static uchar *get_tmpdir(THD *thd) static uchar *get_tmpdir(THD *thd)
{ {
if (opt_mysql_tmpdir) if (opt_mysql_tmpdir)
...@@ -2751,16 +2762,16 @@ static uchar *get_tmpdir(THD *thd) ...@@ -2751,16 +2762,16 @@ static uchar *get_tmpdir(THD *thd)
- Update loop - Update loop
****************************************************************************/ ****************************************************************************/
/* /**
Find variable name in option my_getopt structure used for command line args Find variable name in option my_getopt structure used for
command line args.
SYNOPSIS @param opt option structure array to search in
find_option() @param name variable name
opt option structure array to search in
name variable name
RETURN VALUES @retval
0 Error 0 Error
@retval
ptr pointer to option structure ptr pointer to option structure
*/ */
...@@ -2783,8 +2794,8 @@ static struct my_option *find_option(struct my_option *opt, const char *name) ...@@ -2783,8 +2794,8 @@ static struct my_option *find_option(struct my_option *opt, const char *name)
} }
/* /**
Return variable name and length for hashing of variables Return variable name and length for hashing of variables.
*/ */
static uchar *get_sys_var_length(const sys_var *var, size_t *length, static uchar *get_sys_var_length(const sys_var *var, size_t *length,
...@@ -2986,17 +2997,17 @@ int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count) ...@@ -2986,17 +2997,17 @@ int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count)
} }
/* /**
Find a user set-table variable Find a user set-table variable.
SYNOPSIS @param str Name of system variable to find
intern_find_sys_var() @param length Length of variable. zero means that we should use strlen()
str Name of system variable to find
length Length of variable. zero means that we should use strlen()
on the variable on the variable
@param no_error Refuse to emit an error, even if one occurred.
RETURN VALUES @retval
pointer pointer to variable definitions pointer pointer to variable definitions
@retval
0 Unknown variable (error message is given) 0 Unknown variable (error message is given)
*/ */
...@@ -3017,25 +3028,23 @@ sys_var *intern_find_sys_var(const char *str, uint length, bool no_error) ...@@ -3017,25 +3028,23 @@ sys_var *intern_find_sys_var(const char *str, uint length, bool no_error)
} }
/* /**
Execute update of all variables Execute update of all variables.
SYNOPSIS
sql_set
THD Thread id
set_var List of variables to update
DESCRIPTION
First run a check of all variables that all updates will go ok. First run a check of all variables that all updates will go ok.
If yes, then execute all updates, returning an error if any one failed. If yes, then execute all updates, returning an error if any one failed.
This should ensure that in all normal cases none all or variables are This should ensure that in all normal cases none all or variables are
updated updated.
RETURN VALUE @param THD Thread id
@param var_list List of variables to update
@retval
0 ok 0 ok
@retval
1 ERROR, message sent (normally no variables was updated) 1 ERROR, message sent (normally no variables was updated)
@retval
-1 ERROR, message not sent -1 ERROR, message not sent
*/ */
...@@ -3064,20 +3073,19 @@ err: ...@@ -3064,20 +3073,19 @@ err:
} }
/* /**
Say if all variables set by a SET support the ONE_SHOT keyword (currently, Say if all variables set by a SET support the ONE_SHOT keyword
only character set and collation do; later timezones will). (currently, only character set and collation do; later timezones
will).
SYNOPSIS
not_all_support_one_shot @param var_list List of variables to update
set_var List of variables to update
NOTES @note
It has a "not_" because it makes faster tests (no need to "!") It has a "not_" because it makes faster tests (no need to "!")
RETURN VALUE @retval
0 all variables of the list support ONE_SHOT 0 all variables of the list support ONE_SHOT
@retval
1 at least one does not support ONE_SHOT 1 at least one does not support ONE_SHOT
*/ */
...@@ -3136,16 +3144,16 @@ int set_var::check(THD *thd) ...@@ -3136,16 +3144,16 @@ int set_var::check(THD *thd)
} }
/* /**
Check variable, but without assigning value (used by PS) Check variable, but without assigning value (used by PS).
SYNOPSIS @param thd thread handler
set_var::light_check()
thd thread handler
RETURN VALUE @retval
0 ok 0 ok
@retval
1 ERROR, message sent (normally no variables was updated) 1 ERROR, message sent (normally no variables was updated)
@retval
-1 ERROR, message not sent -1 ERROR, message not sent
*/ */
int set_var::light_check(THD *thd) int set_var::light_check(THD *thd)
...@@ -3193,16 +3201,16 @@ int set_var_user::check(THD *thd) ...@@ -3193,16 +3201,16 @@ int set_var_user::check(THD *thd)
} }
/* /**
Check variable, but without assigning value (used by PS) Check variable, but without assigning value (used by PS).
SYNOPSIS @param thd thread handler
set_var_user::light_check()
thd thread handler
RETURN VALUE @retval
0 ok 0 ok
@retval
1 ERROR, message sent (normally no variables was updated) 1 ERROR, message sent (normally no variables was updated)
@retval
-1 ERROR, message not sent -1 ERROR, message not sent
*/ */
int set_var_user::light_check(THD *thd) int set_var_user::light_check(THD *thd)
...@@ -3377,13 +3385,15 @@ bool sys_var_thd_table_type::update(THD *thd, set_var *var) ...@@ -3377,13 +3385,15 @@ bool sys_var_thd_table_type::update(THD *thd, set_var *var)
Functions to handle sql_mode Functions to handle sql_mode
****************************************************************************/ ****************************************************************************/
/* /**
Make string representation of mode Make string representation of mode.
SYNOPSIS @param[in] thd thread handler
thd in thread handler @param[in] val sql_mode value
val in sql_mode value @param[out] len pointer on length of string
rep out pointer pointer to string with sql_mode representation
@return
pointer to string with sql_mode representation
*/ */
bool bool
...@@ -3454,7 +3464,7 @@ void fix_sql_mode_var(THD *thd, enum_var_type type) ...@@ -3454,7 +3464,7 @@ void fix_sql_mode_var(THD *thd, enum_var_type type)
} }
} }
/* Map database specific bits to function bits */ /** Map database specific bits to function bits. */
ulong fix_sql_mode(ulong sql_mode) ulong fix_sql_mode(ulong sql_mode)
{ {
......
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment