]> granicus.if.org Git - postgresql/blob - contrib/lo/lo.sql.in
pgindent run on all C files. Java run to follow. initdb/regression
[postgresql] / contrib / lo / lo.sql.in
1 --
2 --      PostgreSQL code for LargeObjects
3 --
4 --      $Id: lo.sql.in,v 1.6 2000/11/21 21:51:58 tgl Exp $
5 --
6 --
7 --      Create the data type
8 --
9
10 -- used by the lo type, it takes an oid and returns an lo object
11 create function lo_in(opaque)
12         returns opaque
13         as 'MODULE_PATHNAME'
14         language 'c';
15
16 -- used by the lo type, it returns the oid of the object
17 create function lo_out(opaque)
18         returns opaque
19         as 'MODULE_PATHNAME'
20         language 'c';
21
22 -- finally the type itself
23 create type lo (
24         internallength = 4,
25         externallength = variable,
26         input = lo_in,
27         output = lo_out
28 );
29
30 -- this returns the oid associated with a lo object
31 create function lo_oid(lo)
32         returns oid
33         as 'MODULE_PATHNAME'
34         language 'c';
35
36 -- same function, named to allow it to be used as a type coercion, eg:
37 --    create table a (image lo);
38 --    select image::oid from a;
39 --
40 create function oid(lo)
41         returns oid
42         as 'MODULE_PATHNAME', 'lo_oid'
43         language 'c';
44
45 -- this allows us to convert an oid to a managed lo object
46 -- ie: insert into test values (lo_import('/fullpath/file')::lo);
47 create function lo(oid)
48         returns lo
49         as 'MODULE_PATHNAME'
50         language 'c';
51
52 -- This is used in triggers
53 create function lo_manage()
54         returns opaque
55         as 'MODULE_PATHNAME'
56         language 'c';