3 pgrowlocks README ÀаæãÉ×
7 pgrowlocks¤Ï¡¤»ØÄꤵ¤ì¤¿¥Æ¡¼¥Ö¥ë¤Î¹Ô¥í¥Ã¥¯¤Ë´Ø¤¹¤ë¾ðÊó¤òɽ¼¨¤·¤Þ¤¹¡¥
9 pgrowlocks¤ÎÊÖ¤¹·¿¤Ï¡¤°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡¥
11 CREATE TYPE pgrowlocks_type AS (
12 locked_row TID, -- row TID
13 lock_type TEXT, -- lock type
14 locker XID, -- locking XID
15 multi bool, -- multi XID?
16 xids xid[], -- multi XIDs
17 pids INTEGER[] -- locker's process id
22 test=# SELECT * FROM pgrowlocks('t1');
23 locked_row | lock_type | locker | multi | xids | pids
24 ------------+-----------+--------+-------+-----------+---------------
25 (0,1) | Shared | 19 | t | {804,805} | {29066,29068}
26 (0,2) | Shared | 19 | t | {804,805} | {29066,29068}
27 (0,3) | Exclusive | 804 | f | {804} | {29066}
28 (0,4) | Exclusive | 804 | f | {804} | {29066}
33 locked_row -- ¥í¥Ã¥¯¤µ¤ì¤¿¹Ô¤Î¥¿¥×¥ëID(TID)
34 lock_type -- ¶¦Í¥í¥Ã¥¯¤Ê¤é"Shared"¡¤ÇÓ¾¥í¥Ã¥¯¤Ê¤é"Exclusive"
35 locker -- ¥í¥Ã¥¯¤ò¤«¤±¤Æ¤¤¤ë¥È¥é¥ó¥¶¥¯¥·¥ç¥óID[Ãí1]
36 multi -- locker¤¬¥Þ¥ë¥Á¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤Ê¤ét¤½¤¦¤Ç¤Ê¤±¤ì¤Ðf
37 xids -- ¥í¥Ã¥¯¤ò¤«¤±¤Æ¤¤¤ë¥È¥é¥ó¥¶¥¯¥·¥ç¥óID[Ãí2]
38 pids -- ¥í¥Ã¥¯¤ò¤«¤±¤Æ¤¤¤ë¥Ð¥Ã¥¯¥¨¥ó¥É¥×¥í¥»¥¹¤Î¥×¥í¥»¥¹ID[Ãí2]
40 [Ãí1: locker¤¬¥Þ¥ë¥Á¤Ê¤é¡¤¥È¥é¥ó¥¶¥¯¥·¥ç¥óID¤Ç¤Ï¤Ê¤¯¤Æ¥Þ¥ë¥ÁID¤Ë¤Ê¤ê
43 [Ãí2: locker¤¬¥Þ¥ë¥Á¤Î¾ì¹ç¡¤Ê£¿ô¤Î¥Ç¡¼¥¿¤¬É½¼¨¤µ¤ì¤Þ¤¹¡¥]
45 2. pgrowlocks¤Î¥¤¥ó¥¹¥È¡¼¥ë
47 pgrowlocks¤Î¥¤¥ó¥¹¥È¡¼¥ë¤Ë¤Ï¡¤PostgreSQL¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤¿¤È¤¤Î¥½¡¼
48 ¥¹¥Ä¥ê¡¼¤¬É¬ÍפǤ¹¡¥º£¤Î¤È¤³¤íÂбþ¤·¤Æ¤¤¤ë¥Ð¡¼¥¸¥ç¥ó¤ÏPostgreSQL
51 ¤³¤³¤Ç¤ÏPostgreSQL¤Î¥½¡¼¥¹¤Ï/usr/local/src/postgresql-8.1/¤ËŸ³«¤µ
52 ¤ì¤Æ¤¤¤ë¤â¤Î¤È¤·¤Þ¤¹¡¥
54 1) pgrowlocks¤Î¥½¡¼¥¹¤òŸ³«¤·¤Þ¤¹¡¥¥½¡¼¥¹¥Õ¥¡¥¤¥ë¤Ï
55 /tmp/pgrowlocks-1.0.tar.gz¤ËÃÖ¤¤¤Æ¤¢¤ë¤â¤Î¤È¤·¤Þ¤¹¡¥
57 $ cd /usr/local/src/postgresql-8.1/contrib
58 $ tar xfz pgrowlocks-1.0.tar.gz
60 2) PostgreSQL 8.0¤Î¾ì¹ç¤Ï¡¤¥½¡¼¥¹¤Î°ìÉô¤Ë½¤Àµ¤¬É¬ÍפǤ¹¡¥
61 pgrowlocks.c¤Î61¹ÔÌÜÊÕ¤ê¤Ë
63 #undef MAKERANGEVARFROMNAMELIST_HAS_TWO_ARGS
65 ¤È¤¤¤¦¤Î¤¬¤¢¤ë¤Î¤Ç¡¤¤³¤ì¤ò
67 #define MAKERANGEVARFROMNAMELIST_HAS_TWO_ARGS
69 ¤Ë½ñ¤´¹¤¨¤Þ¤¹(undef->define¤Ë¤·¤Þ¤¹)¡¥
71 3) ¥³¥ó¥Ñ¥¤¥ë¤·¤Æ´Ø¿ô¤Î¶¦Í¥é¥¤¥Ö¥é¥ê¤ò¥¤¥ó¥¹¥È¡¼¥ë¤·¤Þ¤¹¡¥
76 4) ¥æ¡¼¥¶ÄêµÁ´Ø¿ô¤òÅÐÏ¿¤·¤Þ¤¹¡¥
78 $ psql -e -f /usr/local/pgsql/share/contrib/pgrowlocks.sql test
80 ¤³¤ÎÎã¤Ç¤Ï"test"¤È¤¤¤¦¥Ç¡¼¥¿¥Ù¡¼¥¹¤ËÅÐÏ¿¤·¤Æ¤¤¤Þ¤¹¤¬¡¤¤â¤·Â¾¤Î¥Ç¡¼
81 ¥¿¥Ù¡¼¥¹¤ËÅÐÏ¿¤¹¤ë¾ì¹ç¤Ï¤³¤³¤òÆɤßÂؤ¨¤Æ¤¯¤À¤µ¤¤¡¥
85 pgrowlocks¤Î¸Æ¤Ó½Ð¤··Á¼°¤Ï°Ê²¼¤Ç¤¹¡¥
87 CREATE OR REPLACE FUNCTION pgrowlocks(text) RETURNS pgrowlocks_type
88 AS 'MODULE_PATHNAME', 'pgrowlocks'
89 LANGUAGE 'c' WITH (isstrict);
93 ´Ø¿ô¤ÎÌá¤ê¤Ïpgrowlocks_type·¿¤Ç¤¹¡¥
95 pgrowlocks¤Ï¥Æ¡¼¥Ö¥ë¤ËAccessShareLock¥í¥Ã¥¯¤ò¤«¤±¡¤1¹Ô¤º¤ÄÆɤ߽Ф·
96 ¤Æ¤Ï¹Ô¥í¥Ã¥¯¤¬¤«¤«¤Ã¤Æ¤¤¤ë¤«¤É¤¦¤«¥Á¥§¥Ã¥¯¤·¤Þ¤¹¡¥°Ê²¼¤ÎÅÀ¤ËÃí°Õ¤·
99 1) ³ºÅö¥Æ¡¼¥Ö¥ë¤ËÇÓ¾¥í¥Ã¥¯¤¬¤«¤«¤Ã¤Æ¤¤¤ë¤È¡¤pgrowlocks¤Î¼Â¹Ô¤Ï¥Ö¥í¥Ã
102 2) pgrowlocks¤Î¼Â¹ÔÃæ¤Ë¿·¤¿¤Ë¤«¤«¤Ã¤¿¤ê¡¤²ò½ü¤µ¤ì¤¿¹Ô¥í¥Ã¥¯¤Ë´Ø¤¹¤ë
103 ¾ðÊó¤Ïpgrowlocks¤Î¼Â¹Ô·ë²Ì¤ËÈ¿±Ç¤µ¤ì¤Æ¤¤¤Ê¤¤²ÄǽÀ¤¬¤¢¤ê¤Þ¤¹¡¥
106 pgrowlocks¤Ï¥í¥Ã¥¯¤µ¤ì¤¿¹Ô¤ÎÆâÍƤÏɽ¼¨¤·¤Þ¤»¤ó¡¥¹ÔÆâÍƤò¸«¤¿¤¤¾ì¹ç
107 ¤Ï¡¤¥Æ¡¼¥Ö¥ë¤òpgrowlocks¤Îlocked_rowsÎó¤Ç·ë¹ç¤·¤Þ¤¹¡¥Îã¤ò¼¨¤·¤Þ¤¹¡¥
109 SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p WHERE p.locked_ row = a.ctid;
112 4. pgrowlocks¤Î¥é¥¤¥»¥ó¥¹¾ò·ï¤Ë¤Ä¤¤¤Æ
114 pgrowlocks.c¤ÎËÁƬ¤Ë½ñ¤¤¤Æ¤¢¤ëÄ̤ê¤Ç¤¹(½¤ÀµBSD¥é¥¤¥»¥ó¥¹¤Ë½à¤¸¤Æ¤¤
115 ¤Þ¤¹)¡¥¤Þ¤¿¡¤pgrowlocks ¤Ï´°Á´¤Ë̵ÊݾڤǤ¹¡¥pgrowlocks ¤ò»ÈÍѤ·¤¿¤³
116 ¤È¤Ë¤è¤Ã¤ÆÀ¸¤¸¤ë¤¤¤«¤Ê¤ë·ë²Ì¤Ë´Ø¤·¤Æ¤âÀÕǤ¤òÉ餤¤Þ¤»¤ó¡¥
120 2006/03/21 pgrowlocks ¥Ð¡¼¥¸¥ç¥ó 1.1¥ê¥ê¡¼¥¹(8.2 current¤Ç¥Æ¥¹¥È)
121 2005/08/22 pgrowlocks ¥Ð¡¼¥¸¥ç¥ó 1.0¥ê¥ê¡¼¥¹