summaryrefslogtreecommitdiff
path: root/contrib/lo
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/lo')
-rw-r--r--contrib/lo/Makefile65
-rwxr-xr-xcontrib/lo/README2
-rw-r--r--contrib/lo/drop.sql21
-rw-r--r--contrib/lo/lo.sql.in15
-rwxr-xr-xcontrib/lo/test.sql57
5 files changed, 49 insertions, 111 deletions
diff --git a/contrib/lo/Makefile b/contrib/lo/Makefile
index e091049293..ed6f9c92b3 100644
--- a/contrib/lo/Makefile
+++ b/contrib/lo/Makefile
@@ -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 ../Makefile.global
-include $(SRCDIR)/Makefile.global
+NAME = lo
-CONTRIBDIR=$(LIBDIR)/modules
+PROGRAM =
+OBJS = $(NAME).o
+DOCS = $(NAME).doc
+SQLS = $(NAME).sql
+BINS =
+EXAMPLES=
+MODS = $(NAME)$(DLSUFFIX)
-CFLAGS+= $(CFLAGS_SL)
+CFLAGS += -I. $(CFLAGS_SL)
ifdef REFINT_VERBOSE
CFLAGS+= -DREFINT_VERBOSE
endif
-TARGETS= lo$(DLSUFFIX) lo.sql
+OTHER_CLEAN = $(SQLS)
+
+all: $(MODS) $(SQLS)
-CLEANFILES+= $(TARGETS)
-all:: $(TARGETS)
+%.sql: %.sql.in
+ $(SED) "s|MODULE_PATHNAME|$(CONTRIB_MODDIR)/$@|" < $< > $@
-install:: all $(CONTRIBDIR)
- for f in *$(DLSUFFIX); do $(INSTALL) -c $$f $(CONTRIBDIR)/$$f; done
-$(CONTRIBDIR):
- mkdir -p $(CONTRIBDIR)
+install: install_doc install_sql install_mod
-%.sql: %.sql.in
- rm -f $@; \
- C=`pwd`; \
- sed -e "s:_OBJWD_:$(CONTRIBDIR):g" \
- -e "s:_DLSUFFIX_:$(DLSUFFIX):g" < $< > $@
+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
diff --git a/contrib/lo/README b/contrib/lo/README
index 3576d3fe4f..aa06adf084 100755
--- a/contrib/lo/README
+++ b/contrib/lo/README
@@ -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
diff --git a/contrib/lo/drop.sql b/contrib/lo/drop.sql
index 2472715a3d..e69de29bb2 100644
--- a/contrib/lo/drop.sql
+++ b/contrib/lo/drop.sql
@@ -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
diff --git a/contrib/lo/lo.sql.in b/contrib/lo/lo.sql.in
index 869f5ccc54..58390028d0 100644
--- a/contrib/lo/lo.sql.in
+++ b/contrib/lo/lo.sql.in
@@ -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
diff --git a/contrib/lo/test.sql b/contrib/lo/test.sql
index 0c0da2cfd6..e69de29bb2 100755
--- a/contrib/lo/test.sql
+++ b/contrib/lo/test.sql
@@ -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