Skip to content

Commit 57f0447

Browse files
Fix search path for psql function
This ensures that all calls of the function use the expected searchpath and the tables of our schema can be found. As our migration-import doesn't set the searchpath when inserting new documents but uses fully qualified table names this leads to the job failing as it is not finding the tables. RISDEV-6261
1 parent 3e6ab62 commit 57f0447

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
CREATE OR REPLACE FUNCTION update_eli_tables()
2+
RETURNS trigger AS
3+
$$
4+
BEGIN
5+
INSERT INTO norm_expression
6+
VALUES (
7+
-- see definition of dokumente.eli_norm_manifestation
8+
((xpath(
9+
'//*[local-name()="act"]/*[local-name()="meta"]/*[local-name()="identification"]/*[local-name()="FRBRExpression"]/*[local-name()="FRBRuri"]/@value'::text,
10+
NEW.xml))[1])::text)
11+
ON CONFLICT DO NOTHING;
12+
INSERT INTO norm_manifestation
13+
VALUES (
14+
-- see definition of dokumente.eli_norm_manifestation
15+
(regexp_replace(((xpath(
16+
'(//*[local-name()="act"]/*[local-name()="meta"]/*[local-name()="identification"]/*[local-name()="FRBRManifestation"]/*[local-name()="FRBRuri"]/@value)'::text,
17+
NEW.xml))[1])::text, '/[^/]*$'::text, ''::text)),
18+
-- see definition of dokumente.eli_norm_expression
19+
((xpath(
20+
'//*[local-name()="act"]/*[local-name()="meta"]/*[local-name()="identification"]/*[local-name()="FRBRExpression"]/*[local-name()="FRBRuri"]/@value'::text,
21+
NEW.xml))[1])::text)
22+
ON CONFLICT DO NOTHING;
23+
RETURN NEW;
24+
END;
25+
$$
26+
LANGUAGE 'plpgsql' VOLATILE SET search_path from current;

0 commit comments

Comments
 (0)