mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
b663f3443b
with OPAQUE, as per recent pghackers discussion. I still want to do some more work on the 'cstring' pseudo-type, but I'm going to commit the bulk of the changes now before the tree starts shifting under me ...
57 lines
1.2 KiB
MySQL
57 lines
1.2 KiB
MySQL
--
|
|
-- PostgreSQL code for LargeObjects
|
|
--
|
|
-- $Id: lo.sql.in,v 1.7 2002/08/22 00:01:39 tgl Exp $
|
|
--
|
|
--
|
|
-- Create the data type
|
|
--
|
|
|
|
-- used by the lo type, it takes an oid and returns an lo object
|
|
create function lo_in(cstring)
|
|
returns lo
|
|
as 'MODULE_PATHNAME'
|
|
language 'c';
|
|
|
|
-- used by the lo type, it returns the oid of the object
|
|
create function lo_out(lo)
|
|
returns cstring
|
|
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';
|
|
|
|
-- same function, named to allow it to be used as a type coercion, eg:
|
|
-- create table a (image lo);
|
|
-- select image::oid from a;
|
|
--
|
|
create function oid(lo)
|
|
returns oid
|
|
as 'MODULE_PATHNAME', 'lo_oid'
|
|
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 trigger
|
|
as 'MODULE_PATHNAME'
|
|
language 'c';
|