에서 문서 - 37.3.1.1. "단계별 첫 번째 규칙"
CREATE TABLE shoelace_log (
sl_name text, -- shoelace changed
sl_avail integer, -- new available value
log_who text, -- who did it
log_when timestamp -- when
);
CREATE RULE log_shoelace AS ON UPDATE TO shoelace_data
WHERE NEW.sl_avail <> OLD.sl_avail
DO INSERT INTO shoelace_log VALUES (
NEW.sl_name,
NEW.sl_avail,
current_user,
current_timestamp
);
이제 누군가가합니다 :
(1) UPDATE shoelace_data SET sl_avail = 6 WHERE sl_name = 'sl7';
파서는이 추가 쿼리를 생성합니다.
(2) INSERT INTO shoelace_log VALUES (
shoelace_data.sl_name, 6,
current_user, current_timestamp )
FROM shoelace_data
WHERE 6 <> shoelace_data.sl_avail
AND shoelace_data.sl_name = 'sl7';
질문은 : 쿼리 (1)이 (1) + (2)로 어떻게 다시 쓰여지는지를 알려주는 도구가 있습니까?