ÃæÀî¤È¿½¤·¤Þ¤¹¡£
¤Ï¤¸¤á¤ÆÅê¹Æ¤·¤Þ¤¹¡£
MySQL¤ÎÀèÇÚÊý¡¢¤ª¼ê½À¤é¤«¤Ë¤ª´ê¤¤¤·¤Þ¤¹¡£
¤µ¤Æ¡¢¼«Æ°¥³¥ß¥Ã¥È¤¬¡ÖOFF¡×¤ÇʬΥ¥ì¥Ù¥ë¤¬¡ÖREPEATABLE READ¡×¤Î¾ì¹ç¤È¤¤¤¦¤³¤È¤Ç¤¹¤¬¡¢SQLʸ¤ò¼Â¹Ô¤¹¤ë¤È¤¤ÎÀܳ¥æ¡¼¥¶¤¬°ã¤Ã¤Æ¤¿¤ê¤·¤Þ¤»¤ó¤Ç¤·¤ç¤¦¤«¡©
¤¿¤È¤¨¤Ð¡¢SUPER¸¢¸Â¤Î¥æ¡¼¥¶¤Ç¤¹¤È¡¢¼«Æ°¥³¥ß¥Ã¥È¤ÎÀßÄ̵꤬¸ú¤È¤Ê¤ê¤Þ¤¹¡£
¢¨°Ê²¼¤Î¥µ¥¤¥È¤Î¡Öinit_connect¡×¤Î¡Ö¥Î¡¼¥È¡×¤ò»²¾È¤¯¤À¤µ¤¤¡£
http://dev.mysql.com/doc/refman/5.1/ja/server-system-variables.html
°Ê¾å¤Ç¤¹¡£
Date: Tue, 28 Aug 2012 10:13:57 +0900
From: hiro@freegw.net
Subject: [mysql 15829] Re: mysql¥³¥Þ¥ó¥É¤ÇºÇ¿·¤Î¥Ç¡¼¥¿¤ò»²¾È¤·¤¿¤¤
To: ml@mysql.gr.jp
¤Ò¤í¤Ç¤¹¡£
¤ª¤Ï¤è¤¦¤´¤¶¤¤¤Þ¤¹¡£
»ä¤¬È¯¹Ô¤·¤¿select¤Ï»²¾È¥ª¥ó¥ê¡¼¤Îselect¤Ç¡¢Æ±¤¸select¤òƱ¤¸¤è¤¦¤Ê¥¿¥¤¥ß¥ó¥°¡Ê΢¤Ç¼Â¹Ô¤¹¤ë¥×¥í¥°¥é¥à¤Î½ª »¸å¡Ë¤Ëȯ¹Ô¤·¤Þ¤·¤¿¤¬·ë²Ì¤¬¾ì¹ç¤Ë¤è¤ê°Û¤Ê¤ë¤È¤¤¤¦¸½¾Ý¤Ç¤¹¡¨Â¼¯äéö¾¼äéö¾¼âò¾¼¯äéö¾¼äéö¾¥×¥í¥°¥é¥à¤Îºî¤êÊý¤òº¬ËÜŪ¤Ë²¿¤«´Ö°ã¤¨¤Æ¤¤¤ë¤Î¤«¤âÃΤì¤Þ¤»¤ó¤¬¡¢java¡¢ruby¤È¤â¤ËƱ¤¸¤è¤¦¤Ê¸½¾Ý¤Ë¤Ê¤Ã¤Æ¤·¤Þ¤¦¤Î¤Ç¡¢ºî¤êÊý¤ÎÌäÂê¤Ç¤Ï¤Ê¤¤¤è¤¦¤Ë¤â»×¤¨¤Þ¤¹¡£
Ê£¿ô¤Î¥Æ¡¼¥Ö¥ë¤Ø¤Îinsert¤ò°ì³ç¤·¤Æ¥³¥ß¥Ã¥È¡¢¥í¡¼¥ë¥Ð¥Ã¥¯¤Ç¤¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢¥È¥é¥ó¥¶¥¯¥·¥ç¥óÆâ¤Ç½èÍý¤ò¤·¤Æ¤¤¤ë¤³¤È¤Ï³ÎǧºÑ¤ß¤Ç¤¹¤¬¡¢¥³¥ß¥Ã¥È¤â¤·¤¯¤Ï¥í¡¼¥ë¥Ð¥Ã¥¯¤·¤¿¤³¤È¤òmysql¥³¥Þ¥ó¥É¤¬Ç§¼±¤Ç¤¤ë¤Þ¤Ç¤Ë¿ôÉáÁ¿ô10ÉÃÄøÅÙ¤ÎÃ٤줬ȯÀ¸¤¹¤ë¤³¤È¤Ï¤¢¤ë¤Î¤Ç¤·¤ç¤¦¤«¡©
¤è¤í¤·¤¯¤ª´ê¤¤¤·¤Þ¤¹¡£
2012ǯ8·î28Æü 1:37 Tomohiro 'Tomo-p' KATO
<tomop@teamgedoh.net>:
¡¡¤³¤ó¤Ð¤ó¤Ï¡£¤«¤È¤¦¤Ç¤¹¡£
On 12/08/28 0:31, ¤Ò¤í wrote:
> ¼Â¤Ï¡Ö¤â¤·¤«¤·¤Æ¡×¤È»×¤¤¡¢Îã2¤Î¥Ñ¥¿¡¼¥ó¤ÈƱ¤¸¤è¤¦¤Ëcommit¤ò»î¤·¤Æ¤ß¤¿¤Î¤Ç¤¹¤¬¡¢
> ºÆ¥í¥°¥¤¥ó¤¹¤ë¤Þ¤ÇºÇ¿·¤Î·ë²Ì¤Ï¼è¤ì¤Þ¤»¤ó¤Ç¤·¤¿¡£
> ¤½¤¦¤«¤È»×¤¦¤È¡¢²¿¤â¤·¤Ê¤¯¤Æ¤âÎ㣱¤ÎC3¤ÇºÇ¿·¤Î¥Ç¡¼¥¿¤¬¼è¤ì¤ë»þ¤â¤¢¤ê¤Þ¤·¤¿¡£
> ¤½¤ì¤ÇÅÓÊý¤ËÊë¤ì¤Æ¤·¤Þ¤Ã¤¿¼¡Âè¤Ç¤¹¡£
¡¡¡¡°ì±þ¼Â¸³¤·¤Æ¤ß¤Þ¤·¤¿¡£Æ±ÆâÍƤDz¿ÅÙ¤«¤ä¤Ã¤Æ¤ß¤Þ¤·¤¿¤¬¡¢selectʸ¤Ë
¡¡"LOCK IN SHARE MODE"¤ä"FOR UPDATE" ¤ò¤Ä¤±¤Æ¥í¥Ã¥¯¤ò³ÍÆÀ¤·¤¿¾ì¹ç¤Ë¤Ï¡¢
¡¡commit¤»¤º¤È¤â¹¹¿·¸å¤ÎÆâÍƤò¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¤¬¡¢¥í¥Ã¥¯¤ò³ÍÆÀ¤·¤Ê¤¤Ã±
¡¡½ã¤Êselectʸ¤Î¾ì¹ç¤Ë¤Ï¹¹¿·Á°¤ÎÆâÍƤ·¤«½Ð¤Æ¤¤Þ¤»¤ó¤Ç¤·¤¿¡£
¼Â¸³´Ä¶: VineSeed + MySQL-5.5.25
*¼Â¸³1: ñ½ã¤Êselectʸ
-----------------------------------------------------------------
mysql> select * from test;
+----+------+
| id | val |
+----+------+
| 1 | 100 |
+----+------+
1 row in set (0.00 sec)
(¢¨) ¤³¤³¤ÇÊÌüËö¤«¤é¹¹¿·
mysql> select * from test;
+----+------+
| id | val |
+----+------+
| 1 | 100 | <--------------------- ÊѲ½¤Ê¤·
+----+------+
1 row in set (0.00 sec)
mysql> select * from test; <------------- Ç°¤Î¤¿¤áºÆÅټ¹Ô
+----+------+
| id | val |
+----+------+
| 1 | 100 | <--------------------- ÊѲ½¤Ê¤·
+----+------+
1 row in set (0.01 sec)
mysql> commit; <--------------------- commit¤·¤Æ¤ß¤ë
Query OK, 0 rows affected (0.00 sec)
mysql> select * from test;
+----+------+
| id | val |
+----+------+
| 1 | 200 | <--------------------- ÊѲ½¤¢¤ê
+----+------+
1 row in set (0.00 sec)
-----------------------------------------------------------------
*¼Â¸³2: ¥í¥Ã¥¯¤¢¤êselectʸ¤ò»È¤Ã¤Æ¤ß¤ë
-----------------------------------------------------------------
mysql> select * from test;
+----+------+
| id | val |
+----+------+
| 1 | 200 |
+----+------+
1 row in set (0.00 sec)
(¢¨) ¤³¤³¤ÇÊÌüËö¤«¤é¹¹¿·
mysql> select * from test;
+----+------+
| id | val |
+----+------+
| 1 | 200 | <--------------------- ÊѲ½¤Ê¤·
+----+------+
1 row in set (0.00 sec)
mysql> select * from test for update; <-- ¥í¥Ã¥¯¤¢¤ê¤Çselect¤·¤Æ¤ß¤ë
+----+------+
| id | val |
+----+------+
| 1 | 300 | <--------------------- ÊѲ½¤¢¤ê
+----+------+
1 row in set (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
-----------------------------------------------------------------
¡¡¡¡¤Á¤ç¤Ã¤È¸Å¤¤¤Ç¤¹¤¬¡¢°Ê²¼¤Î¥µ¥¤¥È¤Ë¥È¥é¥ó¥¶¥¯¥·¥ç¥óʬΥ¥ì¥Ù¥ë¤´¤È¤Î
¡¡MySQL¤ÎµóÆ°¤ÎÀâÌÀ¤¬¤¢¤ê¤Þ¤·¤¿¤Î¤Ç¤´Í÷¤¯¤À¤µ¤¤¡£
http://www.y2sunlight.com/ground/?MySQL4.1%2F9.MySQL%A4%CE%BC%C2%B8%B3%2F4.%A5%C8%A5%E9%A5%F3%A5%B6%A5%AF%A5%B7%A5%E7%A5%F3
--
__________________________________________________
_/_/ Tomohiro "Tomo-p" KATO <
tomop@teamgedoh.net>
_/_/ Team Gedoh Network
http://www.teamgedoh.net/
_/_/ Key fingerprint = A6D8 3981 3575 9F00 EFC3 9C2B F03A 5383 9287 74D9