summaryrefslogtreecommitdiff
path: root/contrib/lo/lo.sql.in
blob: 4aa75a60fe17ec9935e6eb411d829d178bcb90af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
--
--	PostgreSQL code for LargeObjects
--
--	$Id: lo.sql.in,v 1.4 2000/06/19 13:53:42 momjian Exp $
--
--
--	Create the data type
--

-- used by the lo type, it takes an oid and returns an lo object
create function lo_in(opaque)
	returns opaque
	as 'MODULE_PATHNAME'
	language 'c';

-- used by the lo type, it returns the oid of the object
create function lo_out(opaque)
	returns opaque
	as 'MODULE_PATHNAME'
	language 'c';

-- finally the type itself
create type lo (
	internallength = 4,
	externallength = variable,
	input = lo_in,
	output = lo_out
);

-- this returns the oid associated with a lo object
create function lo_oid(lo)
	returns oid
	as 'MODULE_PATHNAME'
	language 'c';

-- this allows us to convert an oid to a managed lo object
-- ie: insert into test values (lo_import('/fullpath/file')::lo);
create function lo(oid)
	returns lo
	as 'MODULE_PATHNAME'
	language 'c';

-- This is used in triggers
create function lo_manage()
	returns opaque
	as 'MODULE_PATHNAME'
	language 'newC';

-- This allows us to map lo to oid
--
-- eg:
--    create table a (image lo);
--    select image::oid from a;
--
create function oid(lo) returns oid as 'select lo_oid($1)' language 'sql';