mysql name const_procedure中的mysql内部函数NAME_CONST

mysql存储过程中的本地变量会被一个内部函数name_const转化,似乎是专门为存储过程设计的,没有提到有其它特别之处.

delimiter //

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中引入,详细解释见

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.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值