@@ -119,14 +119,14 @@ create trigger tg_room_ad after delete
119
119
-- * BEFORE INSERT or UPDATE on WSlot
120
120
-- * - Check that room exists
121
121
-- ************************************************************
122
- create function tg_wslot_biu() returns trigger as '
122
+ create function tg_wslot_biu() returns trigger as $$
123
123
begin
124
124
if count(*) = 0 from Room where roomno = new.roomno then
125
- raise exception '' Room % does not exist' ', new.roomno;
125
+ raise exception 'Room % does not exist', new.roomno;
126
126
end if;
127
127
return new;
128
128
end;
129
- ' language ' plpgsql' ;
129
+ $$ language plpgsql;
130
130
create trigger tg_wslot_biu before insert or update
131
131
on WSlot for each row execute procedure tg_wslot_biu();
132
132
-- ************************************************************
@@ -159,18 +159,18 @@ create trigger tg_pfield_ad after delete
159
159
-- * BEFORE INSERT or UPDATE on PSlot
160
160
-- * - Ensure that our patchfield does exist
161
161
-- ************************************************************
162
- create function tg_pslot_biu() returns trigger as '
162
+ create function tg_pslot_biu() returns trigger as $proc$
163
163
declare
164
164
pfrec record;
165
165
rename new to ps;
166
166
begin
167
167
select into pfrec * from PField where name = ps.pfname;
168
168
if not found then
169
- raise exception '' Patchfield "%" does not exist'' , ps.pfname;
169
+ raise exception $$ Patchfield "%" does not exist$$ , ps.pfname;
170
170
end if;
171
171
return ps;
172
172
end;
173
- ' language ' plpgsql' ;
173
+ $proc$ language plpgsql;
174
174
create trigger tg_pslot_biu before insert or update
175
175
on PSlot for each row execute procedure tg_pslot_biu();
176
176
-- ************************************************************
@@ -191,25 +191,25 @@ create trigger tg_system_au after update
191
191
-- * BEFORE INSERT or UPDATE on IFace
192
192
-- * - set the slotname to IF.sysname.ifname
193
193
-- ************************************************************
194
- create function tg_iface_biu() returns trigger as '
194
+ create function tg_iface_biu() returns trigger as $$
195
195
declare
196
196
sname text;
197
197
sysrec record;
198
198
begin
199
199
select into sysrec * from system where name = new.sysname;
200
200
if not found then
201
- raise exception '' system "%" does not exist'' , new.sysname;
201
+ raise exception $q$ system "%" does not exist$q$ , new.sysname;
202
202
end if;
203
- sname := '' IF.' ' || new.sysname;
204
- sname := sname || ''.' ';
203
+ sname := 'IF.' || new.sysname;
204
+ sname := sname || '. ';
205
205
sname := sname || new.ifname;
206
206
if length(sname) > 20 then
207
- raise exception '' IFace slotname "%" too long (20 char max)' ', sname;
207
+ raise exception 'IFace slotname "%" too long (20 char max)', sname;
208
208
end if;
209
209
new.slotname := sname;
210
210
return new;
211
211
end;
212
- ' language ' plpgsql' ;
212
+ $$ language plpgsql;
213
213
create trigger tg_iface_biu before insert or update
214
214
on IFace for each row execute procedure tg_iface_biu();
215
215
-- ************************************************************
@@ -243,12 +243,10 @@ create trigger tg_hub_a after insert or update or delete
243
243
-- ************************************************************
244
244
-- * Support function to add/remove slots of Hub
245
245
-- ************************************************************
246
- create function tg_hub_adjustslots(bpchar, integer, integer)
246
+ create function tg_hub_adjustslots(hname bpchar,
247
+ oldnslots integer,
248
+ newnslots integer)
247
249
returns integer as '
248
- declare
249
- hname alias for $1;
250
- oldnslots alias for $2;
251
- newnslots alias for $3;
252
250
begin
253
251
if newnslots = oldnslots then
254
252
return 0;
@@ -262,7 +260,7 @@ begin
262
260
values (''HS.dummy'', hname, i, '''');
263
261
end loop;
264
262
return 0;
265
- end;
263
+ end
266
264
' language 'plpgsql';
267
265
-- Test comments
268
266
COMMENT ON FUNCTION tg_hub_adjustslots_wrong(bpchar, integer, integer) IS 'function with args';
@@ -589,11 +587,9 @@ create trigger tg_backlink_a after insert or update or delete
589
587
-- * Support function to set the opponents backlink field
590
588
-- * if it does not already point to the requested slot
591
589
-- ************************************************************
592
- create function tg_backlink_set(bpchar, bpchar)
590
+ create function tg_backlink_set(myname bpchar, blname bpchar)
593
591
returns integer as '
594
592
declare
595
- myname alias for $1;
596
- blname alias for $2;
597
593
mytype char(2);
598
594
link char(4);
599
595
rec record;
@@ -684,8 +680,8 @@ begin
684
680
end if;
685
681
return 0;
686
682
end if;
687
- end;
688
- ' language ' plpgsql' ;
683
+ end
684
+ ' language plpgsql;
689
685
-- ************************************************************
690
686
-- * AFTER INSERT or UPDATE or DELETE on slot with slotlink
691
687
-- * - Ensure that the opponent correctly points back to us
0 commit comments