|
| 1 | +QUERY: create table rtest_t1 (a int4, b int4); |
| 2 | +QUERY: create table rtest_t2 (a int4, b int4); |
| 3 | +QUERY: create table rtest_t3 (a int4, b int4); |
| 4 | +QUERY: create view rtest_v1 as select * from rtest_t1; |
| 5 | +QUERY: create rule rtest_v1_ins as on insert to rtest_v1 do instead |
| 6 | + insert into rtest_t1 values (new.a, new.b); |
| 7 | +QUERY: create rule rtest_v1_upd as on update to rtest_v1 do instead |
| 8 | + update rtest_t1 set a = new.a, b = new.b |
| 9 | + where a = current.a; |
| 10 | +QUERY: create rule rtest_v1_del as on delete to rtest_v1 do instead |
| 11 | + delete from rtest_t1 where a = current.a; |
| 12 | +QUERY: create table rtest_system (sysname text, sysdesc text); |
| 13 | +QUERY: create table rtest_interface (sysname text, ifname text); |
| 14 | +QUERY: create table rtest_person (pname text, pdesc text); |
| 15 | +QUERY: create table rtest_admin (pname text, sysname text); |
| 16 | +QUERY: create rule rtest_sys_upd1 as on update to rtest_system do |
| 17 | + update rtest_interface set sysname = new.sysname |
| 18 | + where sysname = current.sysname; |
| 19 | +QUERY: create rule rtest_sys_upd2 as on update to rtest_system do |
| 20 | + update rtest_admin set sysname = new.sysname |
| 21 | + where sysname = current.sysname; |
| 22 | +QUERY: create rule rtest_sys_del1 as on delete to rtest_system do |
| 23 | + delete from rtest_interface where sysname = current.sysname; |
| 24 | +QUERY: create rule rtest_sys_del2 as on delete to rtest_system do |
| 25 | + delete from rtest_admin where sysname = current.sysname; |
| 26 | +QUERY: create rule rtest_pers_upd as on update to rtest_person do |
| 27 | + update rtest_admin set pname = new.pname where pname = current.pname; |
| 28 | +QUERY: create rule rtest_pers_del as on delete to rtest_person do |
| 29 | + delete from rtest_admin where pname = current.pname; |
| 30 | +QUERY: create table rtest_emp (ename char(20), salary money); |
| 31 | +QUERY: create table rtest_emplog (ename char(20), who name, action char(10), newsal money, oldsal money); |
| 32 | +QUERY: create table rtest_empmass (ename char(20), salary money); |
| 33 | +QUERY: create rule rtest_emp_ins as on insert to rtest_emp do |
| 34 | + insert into rtest_emplog values (new.ename, current_user, |
| 35 | + 'hired', new.salary, '0.00'); |
| 36 | +QUERY: create rule rtest_emp_upd as on update to rtest_emp where new.salary != current.salary do |
| 37 | + insert into rtest_emplog values (new.ename, current_user, |
| 38 | + 'honored', new.salary, current.salary); |
| 39 | +QUERY: create rule rtest_emp_del as on delete to rtest_emp do |
| 40 | + insert into rtest_emplog values (current.ename, current_user, |
| 41 | + 'fired', '0.00', current.salary); |
| 42 | +QUERY: create table rtest_t4 (a int4, b text); |
| 43 | +QUERY: create table rtest_t5 (a int4, b text); |
| 44 | +QUERY: create table rtest_t6 (a int4, b text); |
| 45 | +QUERY: create table rtest_t7 (a int4, b text); |
| 46 | +QUERY: create table rtest_t8 (a int4, b text); |
| 47 | +QUERY: create table rtest_t9 (a int4, b text); |
| 48 | +QUERY: create rule rtest_t4_ins1 as on insert to rtest_t4 |
| 49 | + where new.a >= 10 and new.a < 20 do instead |
| 50 | + insert into rtest_t5 values (new.a, new.b); |
| 51 | +QUERY: create rule rtest_t4_ins2 as on insert to rtest_t4 |
| 52 | + where new.a >= 20 and new.a < 30 do |
| 53 | + insert into rtest_t6 values (new.a, new.b); |
| 54 | +QUERY: create rule rtest_t5_ins as on insert to rtest_t5 |
| 55 | + where new.a > 15 do |
| 56 | + insert into rtest_t7 values (new.a, new.b); |
| 57 | +QUERY: create rule rtest_t6_ins as on insert to rtest_t6 |
| 58 | + where new.a > 25 do instead |
| 59 | + insert into rtest_t8 values (new.a, new.b); |
| 60 | +QUERY: create table rtest_order1 (a int4); |
| 61 | +QUERY: create table rtest_order2 (a int4, b int4, c text); |
| 62 | +QUERY: create sequence rtest_seq; |
| 63 | +QUERY: create rule rtest_order_r3 as on insert to rtest_order1 do instead |
| 64 | + insert into rtest_order2 values (new.a, nextval('rtest_seq'), |
| 65 | + 'rule 3 - this should run 3rd or 4th'); |
| 66 | +QUERY: create rule rtest_order_r4 as on insert to rtest_order1 |
| 67 | + where a < 100 do instead |
| 68 | + insert into rtest_order2 values (new.a, nextval('rtest_seq'), |
| 69 | + 'rule 4 - this should run 2nd'); |
| 70 | +QUERY: create rule rtest_order_r2 as on insert to rtest_order1 do |
| 71 | + insert into rtest_order2 values (new.a, nextval('rtest_seq'), |
| 72 | + 'rule 2 - this should run 1st'); |
| 73 | +QUERY: create rule rtest_order_r1 as on insert to rtest_order1 do instead |
| 74 | + insert into rtest_order2 values (new.a, nextval('rtest_seq'), |
| 75 | + 'rule 1 - this should run 3rd or 4th'); |
| 76 | +QUERY: create table rtest_nothn1 (a int4, b text); |
| 77 | +QUERY: create table rtest_nothn2 (a int4, b text); |
| 78 | +QUERY: create table rtest_nothn3 (a int4, b text); |
| 79 | +QUERY: create table rtest_nothn4 (a int4, b text); |
| 80 | +QUERY: create rule rtest_nothn_r1 as on insert to rtest_nothn1 |
| 81 | + where new.a >= 10 and new.a < 20 do instead (select 1); |
| 82 | +QUERY: create rule rtest_nothn_r2 as on insert to rtest_nothn1 |
| 83 | + where new.a >= 30 and new.a < 40 do instead nothing; |
| 84 | +QUERY: create rule rtest_nothn_r3 as on insert to rtest_nothn2 |
| 85 | + where new.a >= 100 do instead |
| 86 | + insert into rtest_nothn3 values (new.a, new.b); |
| 87 | +QUERY: create rule rtest_nothn_r4 as on insert to rtest_nothn2 |
| 88 | + do instead nothing; |
1 | 89 | QUERY: insert into rtest_t2 values (1, 21);
|
2 | 90 | QUERY: insert into rtest_t2 values (2, 22);
|
3 | 91 | QUERY: insert into rtest_t2 values (3, 23);
|
@@ -252,69 +340,69 @@ QUERY: update rtest_emp set ename = 'wiecx' where ename = 'wiech';
|
252 | 340 | QUERY: update rtest_emp set ename = 'wieck', salary = '6000.00' where ename = 'wiecx';
|
253 | 341 | QUERY: update rtest_emp set salary = '7000.00' where ename = 'wieck';
|
254 | 342 | QUERY: delete from rtest_emp where ename = 'gates';
|
255 |
| -QUERY: select * from rtest_emplog; |
256 |
| -ename |who |action |newsal |oldsal |
257 |
| ---------------------+-----+----------+----------+---------- |
258 |
| -wiech |pgsql|hired |$5,000.00 |$0.00 |
259 |
| -gates |pgsql|hired |$80,000.00|$0.00 |
260 |
| -wieck |pgsql|honored |$6,000.00 |$5,000.00 |
261 |
| -wieck |pgsql|honored |$7,000.00 |$6,000.00 |
262 |
| -gates |pgsql|fired |$0.00 |$80,000.00 |
| 343 | +QUERY: select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog; |
| 344 | +ename |matches user|action |newsal |oldsal |
| 345 | +--------------------+------------+----------+----------+---------- |
| 346 | +wiech |t |hired |$5,000.00 |$0.00 |
| 347 | +gates |t |hired |$80,000.00|$0.00 |
| 348 | +wieck |t |honored |$6,000.00 |$5,000.00 |
| 349 | +wieck |t |honored |$7,000.00 |$6,000.00 |
| 350 | +gates |t |fired |$0.00 |$80,000.00 |
263 | 351 | (5 rows)
|
264 | 352 |
|
265 | 353 | QUERY: insert into rtest_empmass values ('meyer', '4000.00');
|
266 | 354 | QUERY: insert into rtest_empmass values ('maier', '5000.00');
|
267 | 355 | QUERY: insert into rtest_empmass values ('mayr', '6000.00');
|
268 | 356 | QUERY: insert into rtest_emp select * from rtest_empmass;
|
269 |
| -QUERY: select * from rtest_emplog; |
270 |
| -ename |who |action |newsal |oldsal |
271 |
| ---------------------+-----+----------+----------+---------- |
272 |
| -wiech |pgsql|hired |$5,000.00 |$0.00 |
273 |
| -gates |pgsql|hired |$80,000.00|$0.00 |
274 |
| -wieck |pgsql|honored |$6,000.00 |$5,000.00 |
275 |
| -wieck |pgsql|honored |$7,000.00 |$6,000.00 |
276 |
| -gates |pgsql|fired |$0.00 |$80,000.00 |
277 |
| -meyer |pgsql|hired |$4,000.00 |$0.00 |
278 |
| -maier |pgsql|hired |$5,000.00 |$0.00 |
279 |
| -mayr |pgsql|hired |$6,000.00 |$0.00 |
| 357 | +QUERY: select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog; |
| 358 | +ename |matches user|action |newsal |oldsal |
| 359 | +--------------------+------------+----------+----------+---------- |
| 360 | +wiech |t |hired |$5,000.00 |$0.00 |
| 361 | +gates |t |hired |$80,000.00|$0.00 |
| 362 | +wieck |t |honored |$6,000.00 |$5,000.00 |
| 363 | +wieck |t |honored |$7,000.00 |$6,000.00 |
| 364 | +gates |t |fired |$0.00 |$80,000.00 |
| 365 | +meyer |t |hired |$4,000.00 |$0.00 |
| 366 | +maier |t |hired |$5,000.00 |$0.00 |
| 367 | +mayr |t |hired |$6,000.00 |$0.00 |
280 | 368 | (8 rows)
|
281 | 369 |
|
282 | 370 | QUERY: update rtest_empmass set salary = salary + '1000.00';
|
283 | 371 | QUERY: update rtest_emp set salary = rtest_empmass.salary where ename = rtest_empmass.ename;
|
284 |
| -QUERY: select * from rtest_emplog; |
285 |
| -ename |who |action |newsal |oldsal |
286 |
| ---------------------+-----+----------+----------+---------- |
287 |
| -wiech |pgsql|hired |$5,000.00 |$0.00 |
288 |
| -gates |pgsql|hired |$80,000.00|$0.00 |
289 |
| -wieck |pgsql|honored |$6,000.00 |$5,000.00 |
290 |
| -wieck |pgsql|honored |$7,000.00 |$6,000.00 |
291 |
| -gates |pgsql|fired |$0.00 |$80,000.00 |
292 |
| -meyer |pgsql|hired |$4,000.00 |$0.00 |
293 |
| -maier |pgsql|hired |$5,000.00 |$0.00 |
294 |
| -mayr |pgsql|hired |$6,000.00 |$0.00 |
295 |
| -maier |pgsql|honored |$6,000.00 |$5,000.00 |
296 |
| -mayr |pgsql|honored |$7,000.00 |$6,000.00 |
297 |
| -meyer |pgsql|honored |$5,000.00 |$4,000.00 |
| 372 | +QUERY: select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog; |
| 373 | +ename |matches user|action |newsal |oldsal |
| 374 | +--------------------+------------+----------+----------+---------- |
| 375 | +wiech |t |hired |$5,000.00 |$0.00 |
| 376 | +gates |t |hired |$80,000.00|$0.00 |
| 377 | +wieck |t |honored |$6,000.00 |$5,000.00 |
| 378 | +wieck |t |honored |$7,000.00 |$6,000.00 |
| 379 | +gates |t |fired |$0.00 |$80,000.00 |
| 380 | +meyer |t |hired |$4,000.00 |$0.00 |
| 381 | +maier |t |hired |$5,000.00 |$0.00 |
| 382 | +mayr |t |hired |$6,000.00 |$0.00 |
| 383 | +maier |t |honored |$6,000.00 |$5,000.00 |
| 384 | +mayr |t |honored |$7,000.00 |$6,000.00 |
| 385 | +meyer |t |honored |$5,000.00 |$4,000.00 |
298 | 386 | (11 rows)
|
299 | 387 |
|
300 | 388 | QUERY: delete from rtest_emp where ename = rtest_empmass.ename;
|
301 |
| -QUERY: select * from rtest_emplog; |
302 |
| -ename |who |action |newsal |oldsal |
303 |
| ---------------------+-----+----------+----------+---------- |
304 |
| -wiech |pgsql|hired |$5,000.00 |$0.00 |
305 |
| -gates |pgsql|hired |$80,000.00|$0.00 |
306 |
| -wieck |pgsql|honored |$6,000.00 |$5,000.00 |
307 |
| -wieck |pgsql|honored |$7,000.00 |$6,000.00 |
308 |
| -gates |pgsql|fired |$0.00 |$80,000.00 |
309 |
| -meyer |pgsql|hired |$4,000.00 |$0.00 |
310 |
| -maier |pgsql|hired |$5,000.00 |$0.00 |
311 |
| -mayr |pgsql|hired |$6,000.00 |$0.00 |
312 |
| -maier |pgsql|honored |$6,000.00 |$5,000.00 |
313 |
| -mayr |pgsql|honored |$7,000.00 |$6,000.00 |
314 |
| -meyer |pgsql|honored |$5,000.00 |$4,000.00 |
315 |
| -maier |pgsql|fired |$0.00 |$6,000.00 |
316 |
| -mayr |pgsql|fired |$0.00 |$7,000.00 |
317 |
| -meyer |pgsql|fired |$0.00 |$5,000.00 |
| 389 | +QUERY: select ename, who = current_user as "matches user", action, newsal, oldsal from rtest_emplog; |
| 390 | +ename |matches user|action |newsal |oldsal |
| 391 | +--------------------+------------+----------+----------+---------- |
| 392 | +wiech |t |hired |$5,000.00 |$0.00 |
| 393 | +gates |t |hired |$80,000.00|$0.00 |
| 394 | +wieck |t |honored |$6,000.00 |$5,000.00 |
| 395 | +wieck |t |honored |$7,000.00 |$6,000.00 |
| 396 | +gates |t |fired |$0.00 |$80,000.00 |
| 397 | +meyer |t |hired |$4,000.00 |$0.00 |
| 398 | +maier |t |hired |$5,000.00 |$0.00 |
| 399 | +mayr |t |hired |$6,000.00 |$0.00 |
| 400 | +maier |t |honored |$6,000.00 |$5,000.00 |
| 401 | +mayr |t |honored |$7,000.00 |$6,000.00 |
| 402 | +meyer |t |honored |$5,000.00 |$4,000.00 |
| 403 | +maier |t |fired |$0.00 |$6,000.00 |
| 404 | +mayr |t |fired |$0.00 |$7,000.00 |
| 405 | +meyer |t |fired |$0.00 |$5,000.00 |
318 | 406 | (14 rows)
|
319 | 407 |
|
320 | 408 | QUERY: insert into rtest_t4 values (1, 'Record should go to rtest_t4');
|
|
0 commit comments