2 -- This runs some common tests against the type
4 -- It's used just for development
7 -- ignore any errors here - simply drop the table if it already exists
10 -- create the test table
11 CREATE TABLE a (fname name,image lo);
13 -- insert a null object
14 INSERT INTO a VALUES ('null');
16 -- insert an empty large object
17 INSERT INTO a VALUES ('empty','');
19 -- insert a large object based on a file
20 INSERT INTO a VALUES ('/etc/group',lo_import('/etc/group')::lo);
22 -- now select the table
25 -- this select also returns an oid based on the lo column
26 SELECT *,image::oid from a;
28 -- now test the trigger
30 BEFORE UPDATE OR DELETE ON a
32 EXECUTE PROCEDURE lo_manage(image);
35 INSERT INTO a VALUES ('aa','');
37 WHERE fname LIKE 'aa%';
40 UPDATE a SET image=lo_import('/etc/group')::lo
43 WHERE fname LIKE 'aa%';
45 -- update the 'empty' row which should be null
46 UPDATE a SET image=lo_import('/etc/hosts')::lo
49 WHERE fname LIKE 'empty%';
50 UPDATE a SET image=null
53 WHERE fname LIKE 'empty%';
59 WHERE fname LIKE 'aa%';
61 -- This deletes the table contents. Note, if you comment this out, and
62 -- expect the drop table to remove the objects, think again. The trigger
63 -- doesn't get thrown by drop table.
66 -- finally drop the table