1
- --
2
- -- Copyright (c) 2008--2013 Red Hat, Inc.
3
- --
4
- -- This software is licensed to you under the GNU General Public License,
5
- -- version 2 (GPLv2). There is NO WARRANTY for this software, express or
6
- -- implied, including the implied warranties of MERCHANTABILITY or FITNESS
7
- -- FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
8
- -- along with this software; if not, see
9
- -- http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
10
- --
11
- -- Red Hat trademarks are not licensed under GPLv2. No permission is
12
- -- granted to use or replicate Red Hat trademarks that are incorporated
13
- -- in this software or its documentation.
14
- --
15
-
1
+ #! /bin/bash
2
+ #
3
+ # Copyright (c) 2008--2013 Red Hat, Inc.
4
+ #
5
+ # This software is licensed to you under the GNU General Public License,
6
+ # version 2 (GPLv2). There is NO WARRANTY for this software, express or
7
+ # implied, including the implied warranties of MERCHANTABILITY or FITNESS
8
+ # FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
9
+ # along with this software; if not, see
10
+ # http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
11
+ #
12
+ # Red Hat trademarks are not licensed under GPLv2. No permission is
13
+ # granted to use or replicate Red Hat trademarks that are incorporated
14
+ # in this software or its documentation.
15
+ #
16
+
17
+ run_sql () {
18
+ PGHOST= PGHOSTADDR= psql -v ON_ERROR_STOP=1 -U " $POSTGRES_USER " --no-password --no-psqlrc -d susemanager " $@ "
19
+ }
20
+
21
+ cat << EOF | run_sql
16
22
create type evr_t as (
17
23
epoch varchar(16),
18
24
version varchar(512),
@@ -21,12 +27,12 @@ create type evr_t as (
21
27
);
22
28
23
29
create or replace function evr_t(e varchar, v varchar, r varchar, t varchar)
24
- returns evr_t as $ $
25
- select row($1 ,$2 ,$3 ,$4 )::evr_t
26
- $ $ language sql;
30
+ returns evr_t as \$\ $
31
+ select row(\ $ 1,\ $ 2,\ $ 3,\ $ 4)::evr_t
32
+ \$\ $ language sql;
27
33
28
34
create or replace function evr_t_compare( a evr_t, b evr_t )
29
- returns int as $ $
35
+ returns int as \$\ $
30
36
begin
31
37
if a.type = b.type then
32
38
if a.type = 'rpm' then
@@ -45,49 +51,49 @@ begin
45
51
end if;
46
52
end if;
47
53
end;
48
- $ $ language plpgsql immutable strict;
54
+ \$\ $ language plpgsql immutable strict;
49
55
50
56
create or replace function evr_t_lt( a evr_t, b evr_t )
51
- returns boolean as $ $
57
+ returns boolean as \$\ $
52
58
begin
53
59
return evr_t_compare( a, b ) < 0;
54
60
end;
55
- $ $ language plpgsql immutable strict;
61
+ \$\ $ language plpgsql immutable strict;
56
62
57
63
create or replace function evr_t_le( a evr_t, b evr_t )
58
- returns boolean as $ $
64
+ returns boolean as \$\ $
59
65
begin
60
66
return evr_t_compare( a, b ) <= 0;
61
67
end;
62
- $ $ language plpgsql immutable strict;
68
+ \$\ $ language plpgsql immutable strict;
63
69
64
70
create or replace function evr_t_eq( a evr_t, b evr_t )
65
- returns boolean as $ $
71
+ returns boolean as \$\ $
66
72
begin
67
73
return evr_t_compare( a, b ) = 0;
68
74
end;
69
- $ $ language plpgsql immutable strict;
75
+ \$\ $ language plpgsql immutable strict;
70
76
71
77
create or replace function evr_t_ne( a evr_t, b evr_t )
72
- returns boolean as $ $
78
+ returns boolean as \$\ $
73
79
begin
74
80
return evr_t_compare( a, b ) != 0;
75
81
end;
76
- $ $ language plpgsql immutable strict;
82
+ \$\ $ language plpgsql immutable strict;
77
83
78
84
create or replace function evr_t_ge( a evr_t, b evr_t )
79
- returns boolean as $ $
85
+ returns boolean as \$\ $
80
86
begin
81
87
return evr_t_compare( a, b ) >= 0;
82
88
end;
83
- $ $ language plpgsql immutable strict;
89
+ \$\ $ language plpgsql immutable strict;
84
90
85
91
create or replace function evr_t_gt( a evr_t, b evr_t )
86
- returns boolean as $ $
92
+ returns boolean as \$\ $
87
93
begin
88
94
return evr_t_compare( a, b ) > 0;
89
95
end;
90
- $ $ language plpgsql immutable strict;
96
+ \$\ $ language plpgsql immutable strict;
91
97
92
98
create operator < (
93
99
leftarg = evr_t,
@@ -160,13 +166,13 @@ default for type evr_t using btree as
160
166
function 1 evr_t_compare( evr_t, evr_t )
161
167
;
162
168
163
- create or replace function evr_t_as_vre ( a evr_t ) returns varchar as $ $
169
+ create or replace function evr_t_as_vre( a evr_t ) returns varchar as \$\ $
164
170
begin
165
171
return a.version || '-' || a.release || ':' || coalesce(a.epoch, '');
166
172
end;
167
- $ $ language plpgsql immutable strict;
173
+ \$\ $ language plpgsql immutable strict;
168
174
169
- create or replace function evr_t_as_vre_simple ( a evr_t ) returns varchar as $ $
175
+ create or replace function evr_t_as_vre_simple( a evr_t ) returns varchar as \$\ $
170
176
declare
171
177
vre_out VARCHAR(256);
172
178
begin
@@ -177,11 +183,11 @@ begin
177
183
end if;
178
184
return vre_out;
179
185
end;
180
- $ $ language plpgsql immutable strict;
186
+ \$\ $ language plpgsql immutable strict;
181
187
182
188
create or replace function evr_t_larger(a evr_t, b evr_t)
183
189
returns evr_t
184
- as $ $
190
+ as \$\ $
185
191
begin
186
192
if a > b
187
193
then
@@ -190,10 +196,11 @@ begin
190
196
return b;
191
197
end if;
192
198
end;
193
- $ $ language plpgsql immutable strict;
199
+ \$\ $ language plpgsql immutable strict;
194
200
195
201
create aggregate max (
196
202
sfunc=evr_t_larger,
197
203
basetype=evr_t,
198
204
stype=evr_t
199
205
);
206
+ EOF
0 commit comments