mirror of https://github.com/LemmyNet/lemmy.git
Compare commits
8 Commits
f1f8245407
...
eafcbd9ef3
Author | SHA1 | Date |
---|---|---|
dullbananas | eafcbd9ef3 | |
Dull Bananas | 344f11eda6 | |
Dull Bananas | c3f6131645 | |
Dull Bananas | 51ee4b2af4 | |
Dull Bananas | 8bf9ac9626 | |
Dull Bananas | 8762d478aa | |
Dull Bananas | 9c726f1b8c | |
Dull Bananas | 078b2dbb9b |
|
@ -5,6 +5,12 @@
|
||||||
-- (even if only other columns are updated) because triggers can run after the deletion of referenced rows and
|
-- (even if only other columns are updated) because triggers can run after the deletion of referenced rows and
|
||||||
-- before the automatic deletion of the row that references it. This is not a problem for insert or delete.
|
-- before the automatic deletion of the row that references it. This is not a problem for insert or delete.
|
||||||
--
|
--
|
||||||
|
-- After a row update begins, a concurrent update on the same row can't begin until the whole
|
||||||
|
-- transaction that contains the first update is finished. To reduce this locking, statements in
|
||||||
|
-- triggers should be ordered based on the likelihood of concurrent writers. For example, updating
|
||||||
|
-- site_aggregates should be done last because the same row is updated for all local stuff. If
|
||||||
|
-- it were not last, then the locking period for concurrent writers would extend to include the
|
||||||
|
-- time consumed by statements that come after.
|
||||||
--
|
--
|
||||||
--
|
--
|
||||||
-- Create triggers for both post and comments
|
-- Create triggers for both post and comments
|
||||||
|
@ -27,7 +33,7 @@ AS $a$
|
||||||
BEGIN
|
BEGIN
|
||||||
EXECUTE replace($b$
|
EXECUTE replace($b$
|
||||||
-- When a thing gets a vote, update its aggregates and its creator's aggregates
|
-- When a thing gets a vote, update its aggregates and its creator's aggregates
|
||||||
CALL r.create_triggers ('thing_like', 'thing_aggregates_and_person_aggregates', $$
|
CALL r.create_triggers ('thing_like', $$
|
||||||
BEGIN
|
BEGIN
|
||||||
WITH thing_diff AS ( UPDATE
|
WITH thing_diff AS ( UPDATE
|
||||||
thing_aggregates AS a
|
thing_aggregates AS a
|
||||||
|
@ -38,16 +44,18 @@ BEGIN
|
||||||
(thing_like).thing_id, coalesce(sum(count_diff) FILTER (WHERE (thing_like).score = 1), 0) AS upvotes, coalesce(sum(count_diff) FILTER (WHERE (thing_like).score != 1), 0) AS downvotes FROM select_old_and_new_rows AS old_and_new_rows GROUP BY (thing_like).thing_id) AS diff
|
(thing_like).thing_id, coalesce(sum(count_diff) FILTER (WHERE (thing_like).score = 1), 0) AS upvotes, coalesce(sum(count_diff) FILTER (WHERE (thing_like).score != 1), 0) AS downvotes FROM select_old_and_new_rows AS old_and_new_rows GROUP BY (thing_like).thing_id) AS diff
|
||||||
WHERE
|
WHERE
|
||||||
a.thing_id = diff.thing_id
|
a.thing_id = diff.thing_id
|
||||||
RETURNING
|
AND (diff.upvotes, diff.downvotes) != (0, 0)
|
||||||
r.creator_id_from_thing_aggregates (a.*) AS creator_id, diff.upvotes - diff.downvotes AS score)
|
RETURNING
|
||||||
UPDATE
|
r.creator_id_from_thing_aggregates (a.*) AS creator_id, diff.upvotes - diff.downvotes AS score)
|
||||||
person_aggregates AS a
|
UPDATE
|
||||||
SET
|
person_aggregates AS a
|
||||||
thing_score = a.thing_score + diff.score FROM (
|
SET
|
||||||
SELECT
|
thing_score = a.thing_score + diff.score FROM (
|
||||||
creator_id, sum(score) AS score FROM thing_diff GROUP BY creator_id) AS diff
|
SELECT
|
||||||
WHERE
|
creator_id, sum(score) AS score FROM thing_diff GROUP BY creator_id) AS diff
|
||||||
a.person_id = diff.creator_id;
|
WHERE
|
||||||
|
a.person_id = diff.creator_id
|
||||||
|
AND diff.score != 0;
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$);
|
$$);
|
||||||
|
@ -62,7 +70,7 @@ CALL r.post_or_comment ('post');
|
||||||
CALL r.post_or_comment ('comment');
|
CALL r.post_or_comment ('comment');
|
||||||
|
|
||||||
-- Create triggers that update counts in parent aggregates
|
-- Create triggers that update counts in parent aggregates
|
||||||
CALL r.create_triggers ('comment', 'person_aggregates', $$
|
CALL r.create_triggers ('comment', $$
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE
|
UPDATE
|
||||||
person_aggregates AS a
|
person_aggregates AS a
|
||||||
|
@ -76,76 +84,56 @@ BEGIN
|
||||||
r.is_counted (comment)
|
r.is_counted (comment)
|
||||||
GROUP BY (comment).creator_id) AS diff
|
GROUP BY (comment).creator_id) AS diff
|
||||||
WHERE
|
WHERE
|
||||||
a.person_id = diff.creator_id;
|
a.person_id = diff.creator_id
|
||||||
|
AND diff.comment_count != 0;
|
||||||
|
|
||||||
RETURN NULL;
|
WITH post_diff AS (
|
||||||
|
|
||||||
END;
|
|
||||||
|
|
||||||
$$);
|
|
||||||
|
|
||||||
CALL r.create_triggers ('comment', 'site_aggregates', $$
|
|
||||||
BEGIN
|
|
||||||
UPDATE
|
UPDATE
|
||||||
site_aggregates AS a
|
post_aggregates AS a
|
||||||
SET
|
SET
|
||||||
comments = a.comments + diff.comments
|
comments = a.comments + diff.comments,
|
||||||
|
newest_comment_time = GREATEST (a.newest_comment_time, (
|
||||||
|
SELECT
|
||||||
|
published
|
||||||
|
FROM select_new_rows AS new_comment
|
||||||
|
WHERE
|
||||||
|
a.post_id = new_comment.post_id ORDER BY published DESC LIMIT 1)),
|
||||||
|
newest_comment_time_necro = GREATEST (a.newest_comment_time_necro, (
|
||||||
|
SELECT
|
||||||
|
published
|
||||||
|
FROM select_new_rows AS new_comment
|
||||||
|
WHERE
|
||||||
|
a.post_id = new_comment.post_id
|
||||||
|
-- Ignore comments from the post's creator
|
||||||
|
AND a.creator_id != new_comment.creator_id
|
||||||
|
-- Ignore comments on old posts
|
||||||
|
AND a.published > (new_comment.published - '2 days'::interval)
|
||||||
|
ORDER BY published DESC LIMIT 1))
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
|
(comment).post_id,
|
||||||
coalesce(sum(count_diff), 0) AS comments
|
coalesce(sum(count_diff), 0) AS comments
|
||||||
FROM select_old_and_new_rows AS old_and_new_rows
|
FROM
|
||||||
WHERE
|
select_old_and_new_rows AS old_and_new_rows
|
||||||
r.is_counted (comment)
|
WHERE
|
||||||
AND (comment).local) AS diff;
|
r.is_counted (comment)
|
||||||
|
GROUP BY
|
||||||
RETURN NULL;
|
(comment).post_id) AS diff
|
||||||
|
LEFT JOIN post ON post.id = diff.post_id
|
||||||
END;
|
WHERE
|
||||||
|
a.post_id = diff.post_id
|
||||||
$$);
|
RETURNING
|
||||||
|
a.community_id,
|
||||||
CALL r.create_triggers ('comment', 'post_aggregates_and_community_aggregates', $$
|
diff.comments,
|
||||||
BEGIN
|
r.is_counted (post.*) AS include_in_community_aggregates)
|
||||||
WITH post_diff AS (
|
|
||||||
UPDATE
|
|
||||||
post_aggregates AS a
|
|
||||||
SET
|
|
||||||
comments = a.comments + diff.comments,
|
|
||||||
newest_comment_time = GREATEST (a.newest_comment_time, (
|
|
||||||
SELECT
|
|
||||||
published
|
|
||||||
FROM select_new_rows AS new_comment
|
|
||||||
WHERE
|
|
||||||
a.post_id = new_comment.post_id ORDER BY published DESC LIMIT 1)), newest_comment_time_necro = GREATEST (a.newest_comment_time_necro, (
|
|
||||||
SELECT
|
|
||||||
published
|
|
||||||
FROM select_new_rows AS new_comment
|
|
||||||
WHERE
|
|
||||||
a.post_id = new_comment.post_id
|
|
||||||
-- Ignore comments from the post's creator
|
|
||||||
AND a.creator_id != new_comment.creator_id
|
|
||||||
-- Ignore comments on old posts
|
|
||||||
AND a.published > (new_comment.published - '2 days'::interval)
|
|
||||||
ORDER BY published DESC LIMIT 1))
|
|
||||||
FROM (
|
|
||||||
SELECT
|
|
||||||
(comment).post_id, coalesce(sum(count_diff), 0) AS comments
|
|
||||||
FROM select_old_and_new_rows AS old_and_new_rows
|
|
||||||
WHERE
|
|
||||||
r.is_counted (comment)
|
|
||||||
GROUP BY (comment).post_id) AS diff
|
|
||||||
LEFT JOIN post ON post.id = diff.post_id
|
|
||||||
WHERE
|
|
||||||
a.post_id = diff.post_id
|
|
||||||
RETURNING
|
|
||||||
a.community_id, diff.comments, r.is_counted (post.*) AS include_in_community_aggregates)
|
|
||||||
UPDATE
|
UPDATE
|
||||||
community_aggregates AS a
|
community_aggregates AS a
|
||||||
SET
|
SET
|
||||||
comments = a.comments + diff.comments
|
comments = a.comments + diff.comments
|
||||||
FROM (
|
FROM (
|
||||||
SELECT
|
SELECT
|
||||||
community_id, sum(comments) AS comments
|
community_id,
|
||||||
|
sum(comments) AS comments
|
||||||
FROM
|
FROM
|
||||||
post_diff
|
post_diff
|
||||||
WHERE
|
WHERE
|
||||||
|
@ -153,7 +141,23 @@ FROM (
|
||||||
GROUP BY
|
GROUP BY
|
||||||
community_id) AS diff
|
community_id) AS diff
|
||||||
WHERE
|
WHERE
|
||||||
a.community_id = diff.community_id;
|
a.community_id = diff.community_id
|
||||||
|
AND diff.comments != 0;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
site_aggregates AS a
|
||||||
|
SET
|
||||||
|
comments = a.comments + diff.comments
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
coalesce(sum(count_diff), 0) AS comments
|
||||||
|
FROM
|
||||||
|
select_old_and_new_rows AS old_and_new_rows
|
||||||
|
WHERE
|
||||||
|
r.is_counted (comment)
|
||||||
|
AND (comment).local) AS diff
|
||||||
|
WHERE
|
||||||
|
diff.comments != 0;
|
||||||
|
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
|
|
||||||
|
@ -161,7 +165,7 @@ END;
|
||||||
|
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
CALL r.create_triggers ('post', 'person_aggregates', $$
|
CALL r.create_triggers ('post', $$
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE
|
UPDATE
|
||||||
person_aggregates AS a
|
person_aggregates AS a
|
||||||
|
@ -175,49 +179,41 @@ BEGIN
|
||||||
r.is_counted (post)
|
r.is_counted (post)
|
||||||
GROUP BY (post).creator_id) AS diff
|
GROUP BY (post).creator_id) AS diff
|
||||||
WHERE
|
WHERE
|
||||||
a.person_id = diff.creator_id;
|
a.person_id = diff.creator_id
|
||||||
|
AND diff.post_count != 0;
|
||||||
|
|
||||||
RETURN NULL;
|
UPDATE
|
||||||
|
community_aggregates AS a
|
||||||
END;
|
SET
|
||||||
|
posts = a.posts + diff.posts
|
||||||
$$);
|
FROM (
|
||||||
|
SELECT
|
||||||
CALL r.create_triggers ('post', 'site_aggregates', $$
|
(post).community_id,
|
||||||
BEGIN
|
coalesce(sum(count_diff), 0) AS posts
|
||||||
UPDATE
|
FROM
|
||||||
site_aggregates AS a
|
select_old_and_new_rows AS old_and_new_rows
|
||||||
SET
|
WHERE
|
||||||
posts = a.posts + diff.posts
|
r.is_counted (post)
|
||||||
FROM (
|
GROUP BY
|
||||||
SELECT
|
(post).community_id) AS diff
|
||||||
coalesce(sum(count_diff), 0) AS posts
|
|
||||||
FROM select_old_and_new_rows AS old_and_new_rows
|
|
||||||
WHERE
|
|
||||||
r.is_counted (post)
|
|
||||||
AND (post).local) AS diff;
|
|
||||||
|
|
||||||
RETURN NULL;
|
|
||||||
|
|
||||||
END;
|
|
||||||
|
|
||||||
$$);
|
|
||||||
|
|
||||||
CALL r.create_triggers ('post', 'community_aggregates', $$
|
|
||||||
BEGIN
|
|
||||||
UPDATE
|
|
||||||
community_aggregates AS a
|
|
||||||
SET
|
|
||||||
posts = a.posts + diff.posts
|
|
||||||
FROM (
|
|
||||||
SELECT
|
|
||||||
(post).community_id, coalesce(sum(count_diff), 0) AS posts
|
|
||||||
FROM select_old_and_new_rows AS old_and_new_rows
|
|
||||||
WHERE
|
|
||||||
r.is_counted (post)
|
|
||||||
GROUP BY (post).community_id) AS diff
|
|
||||||
WHERE
|
WHERE
|
||||||
a.community_id = diff.community_id;
|
a.community_id = diff.community_id
|
||||||
|
AND diff.posts != 0;
|
||||||
|
|
||||||
|
UPDATE
|
||||||
|
site_aggregates AS a
|
||||||
|
SET
|
||||||
|
posts = a.posts + diff.posts
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
coalesce(sum(count_diff), 0) AS posts
|
||||||
|
FROM
|
||||||
|
select_old_and_new_rows AS old_and_new_rows
|
||||||
|
WHERE
|
||||||
|
r.is_counted (post)
|
||||||
|
AND (post).local) AS diff
|
||||||
|
WHERE
|
||||||
|
diff.posts != 0;
|
||||||
|
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
|
|
||||||
|
@ -225,7 +221,7 @@ END;
|
||||||
|
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
CALL r.create_triggers ('community', 'site_aggregates', $$
|
CALL r.create_triggers ('community', $$
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE
|
UPDATE
|
||||||
site_aggregates AS a
|
site_aggregates AS a
|
||||||
|
@ -237,7 +233,9 @@ BEGIN
|
||||||
FROM select_old_and_new_rows AS old_and_new_rows
|
FROM select_old_and_new_rows AS old_and_new_rows
|
||||||
WHERE
|
WHERE
|
||||||
r.is_counted (community)
|
r.is_counted (community)
|
||||||
AND (community).local) AS diff;
|
AND (community).local) AS diff
|
||||||
|
WHERE
|
||||||
|
diff.communities != 0;
|
||||||
|
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
|
|
||||||
|
@ -245,7 +243,7 @@ END;
|
||||||
|
|
||||||
$$);
|
$$);
|
||||||
|
|
||||||
CALL r.create_triggers ('person', 'site_aggregates', $$
|
CALL r.create_triggers ('person', $$
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE
|
UPDATE
|
||||||
site_aggregates AS a
|
site_aggregates AS a
|
||||||
|
@ -255,7 +253,9 @@ BEGIN
|
||||||
SELECT
|
SELECT
|
||||||
coalesce(sum(count_diff), 0) AS users
|
coalesce(sum(count_diff), 0) AS users
|
||||||
FROM select_old_and_new_rows AS old_and_new_rows
|
FROM select_old_and_new_rows AS old_and_new_rows
|
||||||
WHERE (person).local) AS diff;
|
WHERE (person).local) AS diff
|
||||||
|
WHERE
|
||||||
|
diff.users != 0;
|
||||||
|
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
|
|
||||||
|
@ -290,7 +290,8 @@ BEGIN
|
||||||
GROUP BY
|
GROUP BY
|
||||||
old_post.community_id) AS diff
|
old_post.community_id) AS diff
|
||||||
WHERE
|
WHERE
|
||||||
a.community_id = diff.community_id;
|
a.community_id = diff.community_id
|
||||||
|
AND diff.comments != 0;
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
@ -303,7 +304,7 @@ CREATE TRIGGER comment_count
|
||||||
-- Count subscribers for communities.
|
-- Count subscribers for communities.
|
||||||
-- subscribers should be updated only when a local community is followed by a local or remote person.
|
-- subscribers should be updated only when a local community is followed by a local or remote person.
|
||||||
-- subscribers_local should be updated only when a local person follows a local or remote community.
|
-- subscribers_local should be updated only when a local person follows a local or remote community.
|
||||||
CALL r.create_triggers ('community_follower', 'community_aggregates', $$
|
CALL r.create_triggers ('community_follower', $$
|
||||||
BEGIN
|
BEGIN
|
||||||
UPDATE
|
UPDATE
|
||||||
community_aggregates AS a
|
community_aggregates AS a
|
||||||
|
@ -316,7 +317,8 @@ BEGIN
|
||||||
LEFT JOIN community ON community.id = (community_follower).community_id
|
LEFT JOIN community ON community.id = (community_follower).community_id
|
||||||
LEFT JOIN person ON person.id = (community_follower).person_id GROUP BY (community_follower).community_id) AS diff
|
LEFT JOIN person ON person.id = (community_follower).person_id GROUP BY (community_follower).community_id) AS diff
|
||||||
WHERE
|
WHERE
|
||||||
a.community_id = diff.community_id;
|
a.community_id = diff.community_id
|
||||||
|
AND (diff.subscribers, diff.subscribers_local) != (0, 0);
|
||||||
|
|
||||||
RETURN NULL;
|
RETURN NULL;
|
||||||
|
|
||||||
|
|
|
@ -64,46 +64,46 @@ $$;
|
||||||
-- not allowed for a `DELETE` trigger)
|
-- not allowed for a `DELETE` trigger)
|
||||||
-- * Transition tables are only provided to the trigger function, not to functions that it calls.
|
-- * Transition tables are only provided to the trigger function, not to functions that it calls.
|
||||||
--
|
--
|
||||||
-- The trigger function body is given as the 2nd argument and can contain these names, which are
|
-- This function can only be called once per table. The trigger function body given as the 2nd argument
|
||||||
-- replaced with a `SELECT` statement in parenthesis if needed:
|
-- and can contain these names, which are replaced with a `SELECT` statement in parenthesis if needed:
|
||||||
-- * `select_old_rows`
|
-- * `select_old_rows`
|
||||||
-- * `select_new_rows`
|
-- * `select_new_rows`
|
||||||
-- * `select_old_and_new_rows` with 2 columns:
|
-- * `select_old_and_new_rows` with 2 columns:
|
||||||
-- 1. `count_diff`: `-1` for old rows and `1` for new rows, which can be used with `sum` to get the number
|
-- 1. `count_diff`: `-1` for old rows and `1` for new rows, which can be used with `sum` to get the number
|
||||||
-- to add to a count
|
-- to add to a count
|
||||||
-- 2. (same name as the trigger's table): the old or new row as a composite value
|
-- 2. (same name as the trigger's table): the old or new row as a composite value
|
||||||
CREATE PROCEDURE r.create_triggers (table_name text, trigger_name text, function_body text)
|
CREATE PROCEDURE r.create_triggers (table_name text, function_body text)
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS $a$
|
AS $a$
|
||||||
DECLARE
|
DECLARE
|
||||||
defs text := $$
|
defs text := $$
|
||||||
-- Delete
|
-- Delete
|
||||||
CREATE FUNCTION r.thing_trigger_name_for_delete_statement ()
|
CREATE FUNCTION r.thing_delete_statement ()
|
||||||
RETURNS TRIGGER
|
RETURNS TRIGGER
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS function_body_delete;
|
AS function_body_delete;
|
||||||
CREATE TRIGGER trigger_name_for_delete_statement
|
CREATE TRIGGER delete_statement
|
||||||
AFTER DELETE ON thing REFERENCING OLD TABLE AS select_old_rows
|
AFTER DELETE ON thing REFERENCING OLD TABLE AS select_old_rows
|
||||||
FOR EACH STATEMENT
|
FOR EACH STATEMENT
|
||||||
EXECUTE FUNCTION r.thing_trigger_name_for_delete_statement ( );
|
EXECUTE FUNCTION r.thing_delete_statement ( );
|
||||||
-- Insert
|
-- Insert
|
||||||
CREATE FUNCTION r.thing_trigger_name_for_insert_statement ( )
|
CREATE FUNCTION r.thing_insert_statement ( )
|
||||||
RETURNS TRIGGER
|
RETURNS TRIGGER
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS function_body_insert;
|
AS function_body_insert;
|
||||||
CREATE TRIGGER trigger_name_for_insert_statement
|
CREATE TRIGGER insert_statement
|
||||||
AFTER INSERT ON thing REFERENCING NEW TABLE AS select_new_rows
|
AFTER INSERT ON thing REFERENCING NEW TABLE AS select_new_rows
|
||||||
FOR EACH STATEMENT
|
FOR EACH STATEMENT
|
||||||
EXECUTE FUNCTION r.thing_trigger_name_for_insert_statement ( );
|
EXECUTE FUNCTION r.thing_insert_statement ( );
|
||||||
-- Update
|
-- Update
|
||||||
CREATE FUNCTION r.thing_trigger_name_for_update_statement ( )
|
CREATE FUNCTION r.thing_update_statement ( )
|
||||||
RETURNS TRIGGER
|
RETURNS TRIGGER
|
||||||
LANGUAGE plpgsql
|
LANGUAGE plpgsql
|
||||||
AS function_body_update;
|
AS function_body_update;
|
||||||
CREATE TRIGGER trigger_name_for_update_statement
|
CREATE TRIGGER update_statement
|
||||||
AFTER UPDATE ON thing REFERENCING OLD TABLE AS select_old_rows NEW TABLE AS select_new_rows
|
AFTER UPDATE ON thing REFERENCING OLD TABLE AS select_old_rows NEW TABLE AS select_new_rows
|
||||||
FOR EACH STATEMENT
|
FOR EACH STATEMENT
|
||||||
EXECUTE FUNCTION r.thing_trigger_name_for_update_statement ( );
|
EXECUTE FUNCTION r.thing_update_statement ( );
|
||||||
$$;
|
$$;
|
||||||
select_old_and_new_rows text := $$ (
|
select_old_and_new_rows text := $$ (
|
||||||
SELECT
|
SELECT
|
||||||
|
@ -135,7 +135,6 @@ DECLARE
|
||||||
FALSE) $$;
|
FALSE) $$;
|
||||||
BEGIN
|
BEGIN
|
||||||
function_body := replace(function_body, 'select_old_and_new_rows', select_old_and_new_rows);
|
function_body := replace(function_body, 'select_old_and_new_rows', select_old_and_new_rows);
|
||||||
defs := replace(defs, 'trigger_name', trigger_name);
|
|
||||||
-- `select_old_rows` and `select_new_rows` are made available as empty tables if they don't already exist
|
-- `select_old_rows` and `select_new_rows` are made available as empty tables if they don't already exist
|
||||||
defs := replace(defs, 'function_body_delete', quote_literal(replace(function_body, 'select_new_rows', empty_select_new_rows)));
|
defs := replace(defs, 'function_body_delete', quote_literal(replace(function_body, 'select_new_rows', empty_select_new_rows)));
|
||||||
defs := replace(defs, 'function_body_insert', quote_literal(replace(function_body, 'select_old_rows', empty_select_old_rows)));
|
defs := replace(defs, 'function_body_insert', quote_literal(replace(function_body, 'select_old_rows', empty_select_old_rows)));
|
||||||
|
|
Loading…
Reference in New Issue