Postgres96 Kompatibilität Vacuum art Ereignis Eventlog » Historie » Version 4
[S] Dominik G, 03.09.2018 10:31
1 | 1 | [X] Daniel S | h1. Postgres96 Kompatibilität Vacuum art Ereignis Eventlog |
---|---|---|---|
2 | |||
3 | * Postgres 96 hat keine public search_path mehr |
||
4 | * Permanente Fehler in Windows Ereignisanzeige, wenn man ältere PRODAT-Versionen mit Postgres 9.6 betreibt |
||
5 | |||
6 | <pre> |
||
7 | <@-2018-08-25 11:44:48 CEST> ERROR: function getsetting(unknown) does not exist at character 8 |
||
8 | <@-2018-08-25 11:44:48 CEST> HINT: No function matches the given name and argument types. You might need to add explicit type casts. |
||
9 | <@-2018-08-25 11:44:48 CEST> QUERY: SELECT GetSetting('akindex') |
||
10 | <@-2018-08-25 11:44:48 CEST> CONTEXT: PL/pgSQL function public.artikel_index(character varying) line 7 at assignment |
||
11 | automatic analyze of table "BUECHEL-HOLDING-LIVE.public.art" |
||
12 | </pre> |
||
13 | |||
14 | Bugfix zur Kompatibilität: (es steht nur public davor) |
||
15 | <pre><code class="sql"> |
||
16 | 4 | [S] Dominik G | DROP INDEX IF EXISTS artikel_index; |
17 | DROP INDEX IF EXISTS artikel_index_like; |
||
18 | DROP INDEX IF EXISTS artikel_index_no_searchstring; |
||
19 | DROP INDEX IF EXISTS artikel_index_no_searchstring_like; |
||
20 | DROP FUNCTION IF EXISTS artikel_index(VARCHAR); |
||
21 | 1 | [X] Daniel S | |
22 | 4 | [S] Dominik G | -- |
23 | 1 | [X] Daniel S | CREATE OR REPLACE FUNCTION public.getsetting(character varying) RETURNS VARCHAR AS |
24 | $$ |
||
25 | DECLARE r VARCHAR; |
||
26 | BEGIN |
||
27 | 2 | [S] Dominik G | SELECT s_inha INTO r FROM public.settings WHERE s_vari=$1; |
28 | RETURN COALESCE(r, ''); |
||
29 | 1 | [X] Daniel S | END$$LANGUAGE plpgsql; |
30 | 4 | [S] Dominik G | -- |
31 | 1 | [X] Daniel S | |
32 | -- Gibt Artikelnummer ohne Index zurück. Wenn Suchstring true, dann mit % am Ende, für Suche aller Artikel unabhängig des Index'. |
||
33 | CREATE OR REPLACE FUNCTION artikel_index(IN ak_nr VARCHAR, IN searchstring BOOLEAN DEFAULT true) RETURNS VARCHAR AS $$ |
||
34 | DECLARE aknr VARCHAR; |
||
35 | indexchar VARCHAR; |
||
36 | posindexchar INTEGER; |
||
37 | BEGIN |
||
38 | indexchar:= public.GetSetting('akindex'::VARCHAR); |
||
39 | |||
40 | IF COALESCE(indexchar, '') = '' THEN RETURN ak_nr; END IF; -- Kein IndexChar definiert, dann raus. |
||
41 | IF StrPos(ak_nr, '%') > 0 THEN RETURN ak_nr; END IF; -- Wildcard für Suche in Artikel, dann raus. |
||
42 | IF StrPos(ak_nr, 'Ø') > 0 THEN RETURN ak_nr; END IF; -- Artikel mit Durchmesserzeichen (Material), dann raus. |
||
43 | |||
44 | posindexchar:= StrPos(reverse(ak_nr), indexchar); |
||
45 | |||
46 | IF (posindexchar = 0) OR (posindexchar > 3) THEN RETURN ak_nr; END IF; -- Kein Index in Artikelnummer, dann raus. |
||
47 | |||
48 | IF posindexchar = 1 THEN -- Indextrenner ist letztes Zeichen, dass heißt der Index ist eingerahmt vom Trenner, z.B. 123'A'. |
||
49 | posindexchar:= StrPos(reverse(SubStr(ak_nr, 1, Length(ak_nr)-1)), indexchar) + 1; |
||
50 | END IF; |
||
51 | |||
52 | 3 | [S] Dominik G | aknr:= SubStr(ak_nr, 1, public.IFTHEN(ak_nr LIKE '%' || indexchar || '%', Length(ak_nr) - posindexchar, 100)::INTEGER); |
53 | 1 | [X] Daniel S | |
54 | IF searchstring THEN -- Wenn Suchstring gewünscht, dann anhängen. |
||
55 | aknr:= aknr || indexchar || '%'; |
||
56 | ELSE |
||
57 | aknr:= rtrim(aknr); -- sonst nur störende Leerzeichen rechts entfernen. |
||
58 | END IF; |
||
59 | |||
60 | RETURN aknr; |
||
61 | END $$ LANGUAGE plpgsql IMMUTABLE; -- nur IMMUTABLE, wenn GetSetting('akindex') sich nicht ändert. |
||
62 | -- |
||
63 | |||
64 | -- Indizes neu |
||
65 | CREATE INDEX artikel_index ON art (artikel_index(ak_nr)); -- 2. Parameter searchstring DEFAULT true |
||
66 | CREATE INDEX artikel_index_like ON art (artikel_index(ak_nr) varchar_pattern_ops); -- 2. Parameter searchstring DEFAULT true |
||
67 | CREATE INDEX artikel_index_no_searchstring ON art (artikel_index(ak_nr, false)); |
||
68 | CREATE INDEX artikel_index_no_searchstring_like ON art (artikel_index(ak_nr, false) varchar_pattern_ops); |
||
69 | -- |
||
70 | |||
71 | 4 | [S] Dominik G | |
72 | DROP INDEX IF EXISTS public.bdea_anf_termweek; |
||
73 | DROP INDEX IF EXISTS public.maschausf_week; |
||
74 | DROP INDEX IF EXISTS public.maschausf_week_end; |
||
75 | DROP INDEX IF EXISTS public.ab2_termweek; |
||
76 | |||
77 | -- |
||
78 | CREATE OR REPLACE FUNCTION public.termweek(timestamp without time zone) |
||
79 | RETURNS integer AS |
||
80 | $BODY$ |
||
81 | BEGIN |
||
82 | RETURN public.week_of_year(CAST($1 AS DATE)); |
||
83 | END$BODY$ |
||
84 | LANGUAGE plpgsql IMMUTABLE; |
||
85 | -- |
||
86 | |||
87 | -- |
||
88 | CREATE OR REPLACE FUNCTION public.termweek_kw(timestamp without time zone) |
||
89 | RETURNS character varying AS |
||
90 | $BODY$ |
||
91 | BEGIN |
||
92 | RETURN public.week_of_year(CAST($1 AS DATE), True); |
||
93 | END$BODY$ |
||
94 | LANGUAGE plpgsql IMMUTABLE; |
||
95 | -- |
||
96 | |||
97 | -- Indizes neu |
||
98 | CREATE INDEX bdea_anf_termweek ON bdea (termweek(ba_anf)); |
||
99 | CREATE INDEX maschausf_week ON maschausf(termweek(ma_anf)); |
||
100 | CREATE INDEX maschausf_week_end ON maschausf(termweek(ma_end)); |
||
101 | CREATE INDEX ab2_termweek ON ab2 (termweek(a2_at)); |
||
102 | -- |
||
103 | 1 | [X] Daniel S | </code></pre> |