我认为有人试图模拟第二个auto_increment值.刚升级到MySQL 5.5.9
CREATE table `job_Title` ( `job_ID` int(11) NOT NulL auto_INCREMENT,`position_ID` int(11) DEFAulT NulL,`Title` varchar(255) ColLATE latin1_general_cs NOT NulL,`selectable` tinyint(4) NOT NulL DEFAulT '0',PRIMARY KEY (`job_ID`),UNIQUE KEY `Title` (`Title`)) ENGINE=InnoDB;create trigger job_position_trigger before insert on job_Title for each row begin if new.position_ID is null then set @position = (select max(position_ID)+1 from job_Title); set new.position_ID = @position; end if; end
错误:线程堆栈溢出:使用9024字节的131072字节堆栈,需要128000字节.使用’MysqLd –thread_stack =#’指定一个
更大的堆栈.’在查询.默认数据库:’mydb’.查询:’将ignore插入job_Title(标题)值(‘Morning Show Personality’)最佳答案我今天遇到了同样的问题,每次触发都会导致堆栈溢出.原来我的Zend社区服务器安装附带了一个默认的my.cnf文件,其中thread_stack大小设置为128K,这导致每个线程中可用于堆栈的131072字节:
MysqL> show variables where `Variable_name` = 'thread_stack';+---------------+--------+| Variable_name | Value |+---------------+--------+| thread_stack | 131072 |+---------------+--------+
所以我在/usr/local/Zend/MysqL/data/my.cnf中注释了这一行,重新启动了MysqL守护进程,瞧! default 192K是
MysqL> show variables where `Variable_name` = 'thread_stack';+---------------+--------+| Variable_name | Value |+---------------+--------+| thread_stack | 196608 |+---------------+--------+
现在你的桌子& tchester的触发器工作完美:)(尽管请注意分隔符)
MysqL> CREATE table `job_Title` ( -> `job_ID` int(11) NOT NulL auto_INCREMENT,-> `position_ID` int(11) DEFAulT NulL,-> `Title` varchar(255) ColLATE latin1_general_cs NOT NulL,-> `selectable` tinyint(4) NOT NulL DEFAulT '0',-> PRIMARY KEY (`job_ID`),-> UNIQUE KEY `Title` (`Title`) -> ) ENGINE=InnoDB;query OK,0 rows affected (0.14 sec)MysqL> DEliMITER &&MysqL> create trigger job_position_trigger -> before insert on job_Title for each row -> begin -> if new.position_ID is null then -> set @position = (select max(position_ID)+1 from job_Title); -> if @position is null then set @position = 1; end if; -> set new.position_ID = @position; -> end if; -> end; -> &&query OK,0 rows affected (0.29 sec)MysqL> DEliMITER ;MysqL> insert into job_Title (Title,selectable) values ("test",1);query OK,1 row affected (0.00 sec)MysqL> insert into job_Title (Title,selectable) values ("test2",3);query OK,1 row affected (0.00 sec)MysqL> select * from job_Title;+--------+-------------+-------+------------+| job_ID | position_ID | Title | selectable |+--------+-------------+-------+------------+| 1 | 1 | test | 1 || 2 | 2 | test2 | 3 |+--------+-------------+-------+------------+2 rows in set (0.00 sec)
你得到的错误,131072字节堆栈使用的9024字节和所需的128000字节是有意义的:9024 128000> 131072. 总结
以上是内存溢出为你收集整理的为什么这个MySQL触发器会导致堆栈溢出?全部内容,希望文章能够帮你解决为什么这个MySQL触发器会导致堆栈溢出?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)