diff options
| author | Bruce Momjian <bruce@momjian.us> | 2000-06-15 19:05:22 +0000 |
|---|---|---|
| committer | Bruce Momjian <bruce@momjian.us> | 2000-06-15 19:05:22 +0000 |
| commit | 5683e704d09caaa29f7a76f0d93ca8fc5f8c0e75 (patch) | |
| tree | 3ae68795e6580e8ca4e464d8416cfc42d1b1bc49 /contrib/lo | |
| parent | f7f177d372750e4f766ccefdf20e1b30d66cba0a (diff) | |
| download | postgresql-5683e704d09caaa29f7a76f0d93ca8fc5f8c0e75.tar.gz | |
Add missing /contrib files to CVS.
Diffstat (limited to 'contrib/lo')
| -rw-r--r-- | contrib/lo/lo_drop.sql | 21 | ||||
| -rw-r--r-- | contrib/lo/lo_test.sql | 57 |
2 files changed, 78 insertions, 0 deletions
diff --git a/contrib/lo/lo_drop.sql b/contrib/lo/lo_drop.sql new file mode 100644 index 0000000000..2472715a3d --- /dev/null +++ b/contrib/lo/lo_drop.sql @@ -0,0 +1,21 @@ +-- +-- This removes the type (and a test table) +-- It's used just for development +-- + +-- remove our test table +drop table a; + +-- now drop any sql based functions associated with the lo type +drop function oid(lo); + +-- now drop the type +drop type lo; + +-- as the type is gone, remove the C based functions +drop function lo_in(opaque); +drop function lo_out(opaque); +drop function lo(oid); +drop function lo_manage(); + +-- the lo stuff is now removed from the system diff --git a/contrib/lo/lo_test.sql b/contrib/lo/lo_test.sql new file mode 100644 index 0000000000..0c0da2cfd6 --- /dev/null +++ b/contrib/lo/lo_test.sql @@ -0,0 +1,57 @@ +-- +-- This runs some common tests against the type +-- +-- It's used just for development +-- + +-- ignore any errors here - simply drop the table if it already exists +drop table a; + +-- create the test table +create table a (fname name,image lo); + +-- insert a null object +insert into a values ('null'); + +-- insert an empty large object +insert into a values ('empty',''); + +-- insert a large object based on a file +insert into a values ('/etc/group',lo_import('/etc/group')::lo); + +-- now select the table +select * from a; + +-- this select also returns an oid based on the lo column +select *,image::oid from a; + +-- now test the trigger +create trigger t_a before update or delete on a for each row execute procedure lo_manage(image); + +-- insert +insert into a values ('aa',''); +select * from a where fname like 'aa%'; + +-- update +update a set image=lo_import('/etc/group')::lo where fname='aa'; +select * from a where fname like 'aa%'; + +-- update the 'empty' row which should be null +update a set image=lo_import('/etc/hosts')::lo where fname='empty'; +select * from a where fname like 'empty%'; +update a set image=null where fname='empty'; +select * from a where fname like 'empty%'; + +-- delete the entry +delete from a where fname='aa'; +select * from a where fname like 'aa%'; + +-- This deletes the table contents. Note, if you comment this out, and +-- expect the drop table to remove the objects, think again. The trigger +-- doesn't get thrown by drop table. +delete from a; + +-- finally drop the table +drop table a; + +-- end of tests |
