Skip to content

Commit dd3bdc3

Browse files
authored
Drop triggers loop fix (#252)
1) Postgres 16.1 throws an error: ``` NOTICE: schema "grestv0" already exists, skipping NOTICE: web_anon exists, skipping... NOTICE: authenticator exists, skipping... NOTICE: role "authenticator" has already been granted membership in role "web_anon" by role "postgres" NOTICE: table "genesis" does not exist, skipping NOTICE: No fuctions found in schema grest ERROR: syntax error at or near "FOR" LINE 1: FOR r IN (SELECT trigger_name, event_object_table FROM infor... ^ Exiting... ```
1 parent e1c9b89 commit dd3bdc3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

files/grest/rpc/db-scripts/basics.sql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,17 @@ END
116116
$do$;
117117

118118
-- DROP EXISTING GREST ADDED TRIGGERS ON PUBLIC SCHEMA
119-
FOR r IN (SELECT trigger_name, event_object_table FROM information_schema.triggers WHERE trigger_schema = 'public' AND action_statement LIKE '%grest.%') LOOP
120-
EXECUTE 'DROP TRIGGER IF EXISTS ' || quote_ident(r.trigger_name) || ' ON ' || quote_ident(r.event_object_table);
121-
END LOOP;
119+
DO
120+
$$
121+
DECLARE
122+
r record;
123+
BEGIN
124+
FOR r IN (SELECT trigger_name, event_object_table FROM information_schema.triggers WHERE trigger_schema = 'public' AND action_statement LIKE '%grest.%')
125+
LOOP
126+
EXECUTE 'DROP TRIGGER IF EXISTS ' || quote_ident(r.trigger_name) || ' ON ' || quote_ident(r.event_object_table);
127+
END LOOP;
128+
END
129+
$$;
122130

123131
-- HELPER FUNCTIONS --
124132
CREATE FUNCTION grest.get_query_pids_partial_match(_query text)

0 commit comments

Comments
 (0)