1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

/contrib patch from Karel.

This commit is contained in:
Bruce Momjian
2000-06-15 18:55:34 +00:00
parent 82c4733116
commit f7f177d372
73 changed files with 1156 additions and 4508 deletions

View File

@ -1,39 +1,60 @@
#
# PostgreSQL lo type
# $Header: /cvsroot/pgsql/contrib/lo/Makefile,v 1.3 2000/06/15 18:54:56 momjian Exp $
#
# Makefile pinched from the ip-mac contrib package
#
# $Id: Makefile,v 1.2 2000/05/29 05:44:27 tgl Exp $
SRCDIR= ../../src
TOPDIR=../..
include $(SRCDIR)/Makefile.global
include ../Makefile.global
CONTRIBDIR=$(LIBDIR)/modules
NAME = lo
CFLAGS+= $(CFLAGS_SL)
PROGRAM =
OBJS = $(NAME).o
DOCS = $(NAME).doc
SQLS = $(NAME).sql
BINS =
EXAMPLES=
MODS = $(NAME)$(DLSUFFIX)
CFLAGS += -I. $(CFLAGS_SL)
ifdef REFINT_VERBOSE
CFLAGS+= -DREFINT_VERBOSE
endif
TARGETS= lo$(DLSUFFIX) lo.sql
OTHER_CLEAN = $(SQLS)
CLEANFILES+= $(TARGETS)
all: $(MODS) $(SQLS)
all:: $(TARGETS)
install:: all $(CONTRIBDIR)
for f in *$(DLSUFFIX); do $(INSTALL) -c $$f $(CONTRIBDIR)/$$f; done
$(CONTRIBDIR):
mkdir -p $(CONTRIBDIR)
%.sql: %.sql.in
rm -f $@; \
C=`pwd`; \
sed -e "s:_OBJWD_:$(CONTRIBDIR):g" \
-e "s:_DLSUFFIX_:$(DLSUFFIX):g" < $< > $@
$(SED) "s|MODULE_PATHNAME|$(CONTRIB_MODDIR)/$@|" < $< > $@
install: install_doc install_sql install_mod
install_doc:
for inst_file in $(DOCS); do \
$(INSTALL) $(INSTL_LIB_OPTS) $$inst_file $(CONTRIB_DOCDIR); \
done
install_sql:
for inst_file in $(SQLS); do \
$(INSTALL) $(INSTL_LIB_OPTS) $$inst_file $(CONTRIB_SQLDIR); \
done
install_mod:
for inst_file in $(MODS); do \
$(INSTALL) $(INSTL_SHLIB_OPTS) $$inst_file $(CONTRIB_MODDIR); \
done
depend dep:
$(CC) -MM -MG $(CFLAGS) *.c > depend
clean:
$(RM) *~ $(OBJS) $(MODS) $(PROGRAM) depend $(OTHER_CLEAN) core log
ifeq (depend,$(wildcard depend))
include depend
endif
clean:
rm -f $(TARGETS) *.o

View File

@ -1,8 +1,6 @@
PostgreSQL type extension for managing Large Objects
----------------------------------------------------
$Id: README,v 1.1 1998/06/16 07:07:11 momjian Exp $
Overview
One of the problems with the JDBC driver (and this affects the ODBC driver

View File

@ -1,21 +0,0 @@
--
-- 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

View File

@ -1,11 +1,8 @@
--
-- PostgreSQL code for LargeObjects
--
-- $Id: lo.sql.in,v 1.2 2000/05/29 01:59:02 tgl Exp $
-- $Id: lo.sql.in,v 1.3 2000/06/15 18:54:56 momjian Exp $
--
load '_OBJWD_/lo_DLSUFFIX_';
--
-- Create the data type
--
@ -13,13 +10,13 @@ load '_OBJWD_/lo_DLSUFFIX_';
-- used by the lo type, it takes an oid and returns an lo object
create function lo_in(opaque)
returns opaque
as '_OBJWD_/lo_DLSUFFIX_'
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 '_OBJWD_/lo_DLSUFFIX_'
as 'MODULE_PATHNAME'
language 'c';
-- finally the type itself
@ -33,20 +30,20 @@ create type lo (
-- this returns the oid associated with a lo object
create function lo_oid(lo)
returns oid
as '_OBJWD_/lo_DLSUFFIX_'
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 '_OBJWD_/lo_DLSUFFIX_'
as 'MODULE_PATHNAME'
language 'c';
-- This is used in triggers
create function lo_manage()
returns opaque
as '_OBJWD_/lo_DLSUFFIX_'
as 'MODULE_PATHNAME'
language 'newC';
-- This allows us to map lo to oid

View File

@ -1,57 +0,0 @@
--
-- 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