procedure中的mysql内部函数NAME_CONST
时间:2008-04-24 来源:cocolala
create procedure pload()
BEGIN
declare j int default 1;
while j<=1000000
do
insert into test(id2,name) values(j,'aaaaaaaaaaaaaaaaaaaaaaa');
set j=j+1;
end while; end;
// delimiter ; call pload(); mysql>show processlist; 查看线程列表,发现类似语句 mysql> show processlist;
+----+------+-----------+------+---------+------+--------+--------------------------------------------------------------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------+------+---------+------+--------+--------------------------------------------------------------------------------------+
| 3 | root | localhost | test | Query | 0 | update | insert into test(id2,name) values( NAME_CONST('j',600610),'aaaaaaaaaaaaaaaaaaaaaaa') | 该函数在5.0.12中引入,详细解释见 http://dev.mysql.com/doc/refman/5.1/en/miscellaneous-functions.html#function_name-const
-
MASTER_POS_WAIT(log_name,log_pos[,timeout])
This function is useful for control of master/slave synchronization. It blocks until the slave has read and applied all updates up to the specified position in the master log. The return value is the number of log events the slave had to wait for to advance to the specified position. The function returns NULL if the slave SQL thread is not started, the slave's master information is not initialized, the arguments are incorrect, or an error occurs. It returns -1 if the timeout has been exceeded. If the slave SQL thread stops while MASTER_POS_WAIT() is waiting, the function returns NULL. If the slave is past the specified position, the function returns immediately.
If a timeout value is specified, MASTER_POS_WAIT() stops waiting when timeout seconds have elapsed. timeout must be greater than 0; a zero or negative timeout means no timeout.
-
NAME_CONST(name,value)
Returns the given value. When used to produce a result set column, NAME_CONST() causes the column to have the given name. The arguments should be constants.
mysql> SELECT NAME_CONST('myname', 14); +--------+ | myname | +--------+ | 14 | +--------+
This function was added in MySQL 5.0.12. It is for internal use only. The server uses it when writing statements from stored routines that contain references to local routine variables, as described in Section 20.4, “Binary Logging of Stored Routines and Triggers”, You might see this function in the output from mysqlbinlog.