Skip to content

Commit

Permalink
Drop triggers loop fix (#252)
Browse files Browse the repository at this point in the history
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...
```
  • Loading branch information
xray-robot authored Dec 18, 2023
1 parent e1c9b89 commit dd3bdc3
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions files/grest/rpc/db-scripts/basics.sql
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,17 @@ END
$do$;

-- DROP EXISTING GREST ADDED TRIGGERS ON PUBLIC SCHEMA
FOR r IN (SELECT trigger_name, event_object_table FROM information_schema.triggers WHERE trigger_schema = 'public' AND action_statement LIKE '%grest.%') LOOP
EXECUTE 'DROP TRIGGER IF EXISTS ' || quote_ident(r.trigger_name) || ' ON ' || quote_ident(r.event_object_table);
END LOOP;
DO
$$
DECLARE
r record;
BEGIN
FOR r IN (SELECT trigger_name, event_object_table FROM information_schema.triggers WHERE trigger_schema = 'public' AND action_statement LIKE '%grest.%')
LOOP
EXECUTE 'DROP TRIGGER IF EXISTS ' || quote_ident(r.trigger_name) || ' ON ' || quote_ident(r.event_object_table);
END LOOP;
END
$$;

-- HELPER FUNCTIONS --
CREATE FUNCTION grest.get_query_pids_partial_match(_query text)
Expand Down

0 comments on commit dd3bdc3

Please sign in to comment.