bitscn.com
1. 安装下载二进制包:由于我的mysql是5.1.48,从官网选择对应的包http://q4m.kazuhooku.com/dist/old/下载后解压a. 将support-files/q4m-forward 拷贝到mysql安装目录/bin下b. 将libqueue_engine.so 拷贝到mysql安装目录/lib/mysql/plugin下执行:$cat support-files/install.sql install plugin queue soname 'libqueue_engine.so';create function queue_wait returns int soname 'libqueue_engine.so';create function queue_end returns int soname 'libqueue_engine.so';create function queue_abort returns int soname 'libqueue_engine.so';create function queue_rowid returns int soname 'libqueue_engine.so';create function queue_set_srcid returns int soname 'libqueue_engine.so';create function queue_compact returns int soname 'libqueue_engine.so';这时候queue引擎的状态还是disable,重启一下mysqld就变成active了。root@test 05:50:59>show plugins;+---------------------+--------+--------------------+---------------------+---------+| name | status | type | library | license |+---------------------+--------+--------------------+---------------------+---------+| binlog | active | storage engine | null | gpl || partition | active | storage engine | null | gpl || csv | active | storage engine | null | gpl || memory | active | storage engine | null | gpl || myisam | active | storage engine | null | gpl || mrg_myisam | active | storage engine | null | gpl || innodb | active | storage engine | ha_innodb_plugin.so | gpl || innodb_trx | active | information schema | ha_innodb_plugin.so | gpl || innodb_locks | active | information schema | ha_innodb_plugin.so | gpl || innodb_lock_waits | active | information schema | ha_innodb_plugin.so | gpl || innodb_cmp | active | information schema | ha_innodb_plugin.so | gpl || innodb_cmp_reset | active | information schema | ha_innodb_plugin.so | gpl || innodb_cmpmem | active | information schema | ha_innodb_plugin.so | gpl || innodb_cmpmem_reset | active | information schema | ha_innodb_plugin.so | gpl || queue | active | storage engine | libqueue_engine.so | gpl |+---------------------+--------+--------------------+---------------------+---------+安装完毕,可以开始玩一把了。2.a.创建一个queue表root@test 05:52:29>create table t1 (a int , b varchar(100)) engine=queue;query ok, 0 rows affected (0.00 sec)尝试插入一条数据: root@test 05:52:51>insert into t1 values (1,sd);error 1598 (hy000): binary logging not possible. message: statement cannot be logged to the binary log in row-based nor statement-based format咿?插入失败,看样子queue不支持binlog复制。好吧,重启把binlog禁用掉。再次执行root@test 05:57:03>insert into t1 values (1,sd); query ok, 1 row affected (0.01 sec)这下插入成功了root@test 05:57:13>insert into t1 values (2,sda),(3,fio),(4,sas);query ok, 3 rows affected (0.00 sec)---------------------////--------------------以下内容有些是参考自官方的一个ppt。------------------////-------------------------那么queue存储引擎和其他存储引擎(例如innodb)有什么不同呢?——不支持主键和索引——支持insert/delete,但不支持update——根据插入数据的顺序进行排序——缓存select count(*)另外该存储引擎使用了多个定义的函数来简化操作,堪称傻瓜式!!!! 针对每个连接有两种模式:owner模式和non-owner模式,在进入owner模式后,该连接所拥有的数据对其他连接而言是不可见的。模式的切换使用函数来实现:a).进入owner模式通常情况下,在发起连接后,处于non-owner模式,当调用函数queue_wait()时,进入owner 模式,根据传递给queue_wait函数的参数,会等待直到可以获得一行数据,在这之后,这行数据对其他连接而言是不可见的。queue_wait的参数类似于如下格式:select * from t1 where queue_wait(“t1”); 等待获得t1内的一行数据,默认超时时间为60秒select * from t1 where queue_wait(“t1: a