aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc G. Fournier <scrappy@hub.org>1998-04-22 04:20:55 +0000
committerMarc G. Fournier <scrappy@hub.org>1998-04-22 04:20:55 +0000
commit04bd26103e9635c6d936ae82efb4ac46d5c0737c (patch)
tree4e0c196cd557caf94f9d53ec1a4c32a822e99b83
parent5b4b3d563d0db16a00909a64090efa877593cffd (diff)
downloadpostgresql-04bd26103e9635c6d936ae82efb4ac46d5c0737c.tar.gz
postgresql-04bd26103e9635c6d936ae82efb4ac46d5c0737c.zip
Missed a few files that were added with the lib/modules patch...
-rw-r--r--contrib/ip_and_mac/ip.sql.in131
-rw-r--r--contrib/ip_and_mac/mac.sql.in125
-rw-r--r--contrib/soundex/Makefile63
-rw-r--r--contrib/soundex/soundex.sql.in57
4 files changed, 376 insertions, 0 deletions
diff --git a/contrib/ip_and_mac/ip.sql.in b/contrib/ip_and_mac/ip.sql.in
new file mode 100644
index 00000000000..1b21507cee5
--- /dev/null
+++ b/contrib/ip_and_mac/ip.sql.in
@@ -0,0 +1,131 @@
+--
+-- PostgreSQL code for IP addresses.
+--
+-- $Id: ip.sql.in,v 1.1 1998/04/22 04:20:30 scrappy Exp $
+--
+
+load '_OBJWD_/ip_DLSUFFIX_';
+
+--
+-- Input and output functions and the type itself:
+--
+
+create function ipaddr_in(opaque)
+ returns opaque
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_out(opaque)
+ returns opaque
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create type ipaddr (
+ internallength = 6,
+ externallength = variable,
+ input = ipaddr_in,
+ output = ipaddr_out
+);
+
+--
+-- The various boolean tests:
+--
+
+create function ipaddr_lt(ipaddr, ipaddr)
+ returns bool
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_le(ipaddr, ipaddr)
+ returns bool
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_eq(ipaddr, ipaddr)
+ returns bool
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_ge(ipaddr, ipaddr)
+ returns bool
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_gt(ipaddr, ipaddr)
+ returns bool
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_ne(ipaddr, ipaddr)
+ returns bool
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_in_net(ipaddr, ipaddr)
+ returns bool
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_mask(ipaddr)
+ returns ipaddr
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+create function ipaddr_bcast(ipaddr)
+ returns ipaddr
+ as '_OBJWD_/ip_DLSUFFIX_'
+ language 'c';
+
+--
+-- Now the operators. Note how some of the parameters to some
+-- of the 'create operator' commands are commented out. This
+-- is because they reference as yet undefined operators, and
+-- will be implicitly defined when those are, further down.
+--
+
+create operator < (
+ leftarg = ipaddr,
+ rightarg = ipaddr,
+-- negator = >=,
+ procedure = ipaddr_lt
+);
+
+create operator <= (
+ leftarg = ipaddr,
+ rightarg = ipaddr,
+-- negator = >,
+ procedure = ipaddr_le
+);
+
+create operator = (
+ leftarg = ipaddr,
+ rightarg = ipaddr,
+ commutator = =,
+-- negator = <>,
+ procedure = ipaddr_eq
+);
+
+create operator >= (
+ leftarg = ipaddr,
+ rightarg = ipaddr,
+ negator = <,
+ procedure = ipaddr_ge
+);
+
+create operator > (
+ leftarg = ipaddr,
+ rightarg = ipaddr,
+ negator = <=,
+ procedure = ipaddr_gt
+);
+
+create operator <> (
+ leftarg = ipaddr,
+ rightarg = ipaddr,
+ negator = =,
+ procedure = ipaddr_ne
+);
+
+--
+-- eof
+--
diff --git a/contrib/ip_and_mac/mac.sql.in b/contrib/ip_and_mac/mac.sql.in
new file mode 100644
index 00000000000..3abbc37154e
--- /dev/null
+++ b/contrib/ip_and_mac/mac.sql.in
@@ -0,0 +1,125 @@
+--
+-- PostgreSQL code for MAC addresses.
+--
+-- $Id: mac.sql.in,v 1.1 1998/04/22 04:20:36 scrappy Exp $
+--
+
+load '_OBJWD_/mac_DLSUFFIX_';
+
+--
+-- Input and output functions and the type itself:
+--
+
+create function macaddr_in(opaque)
+ returns opaque
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+create function macaddr_out(opaque)
+ returns opaque
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+create type macaddr (
+ internallength = 6,
+ externallength = variable,
+ input = macaddr_in,
+ output = macaddr_out
+);
+
+--
+-- The boolean tests:
+--
+
+create function macaddr_lt(macaddr, macaddr)
+ returns bool
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+create function macaddr_le(macaddr, macaddr)
+ returns bool
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+create function macaddr_eq(macaddr, macaddr)
+ returns bool
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+create function macaddr_ge(macaddr, macaddr)
+ returns bool
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+create function macaddr_gt(macaddr, macaddr)
+ returns bool
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+create function macaddr_ne(macaddr, macaddr)
+ returns bool
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+--
+-- Now the operators. Note how some of the parameters to some
+-- of the 'create operator' commands are commented out. This
+-- is because they reference as yet undefined operators, and
+-- will be implicitly defined when those are, further down.
+--
+
+create operator < (
+ leftarg = macaddr,
+ rightarg = macaddr,
+-- negator = >=,
+ procedure = macaddr_lt
+);
+
+create operator <= (
+ leftarg = macaddr,
+ rightarg = macaddr,
+-- negator = >,
+ procedure = macaddr_le
+);
+
+create operator = (
+ leftarg = macaddr,
+ rightarg = macaddr,
+ commutator = =,
+-- negator = <>,
+ procedure = macaddr_eq
+);
+
+create operator >= (
+ leftarg = macaddr,
+ rightarg = macaddr,
+ negator = <,
+ procedure = macaddr_ge
+);
+
+create operator > (
+ leftarg = macaddr,
+ rightarg = macaddr,
+ negator = <=,
+ procedure = macaddr_gt
+);
+
+create operator <> (
+ leftarg = macaddr,
+ rightarg = macaddr,
+ negator = =,
+ procedure = macaddr_ne
+);
+
+--
+-- Finally, the special manufacurer matching function:
+--
+
+create function macaddr_manuf(macaddr)
+ returns text
+ as '_OBJWD_/mac_DLSUFFIX_'
+ language 'c';
+
+--
+-- eof
+--
diff --git a/contrib/soundex/Makefile b/contrib/soundex/Makefile
new file mode 100644
index 00000000000..d95549dc01f
--- /dev/null
+++ b/contrib/soundex/Makefile
@@ -0,0 +1,63 @@
+#-------------------------------------------------------------------------
+#
+# Makefile--
+# Makefile for soundex
+#
+#-------------------------------------------------------------------------
+
+PGDIR = ../..
+SRCDIR = $(PGDIR)/src
+
+include $(SRCDIR)/Makefile.global
+
+INCLUDE_OPT = -I ./ \
+ -I $(SRCDIR)/ \
+ -I $(SRCDIR)/include \
+ -I $(SRCDIR)/interfaces/libpq \
+ -I $(SRCDIR)/port/$(PORTNAME)
+
+CFLAGS += $(INCLUDE_OPT)
+
+ifeq ($(PORTNAME), linux)
+ ifdef LINUX_ELF
+ ifeq ($(CC), gcc)
+ CFLAGS += -fPIC
+ endif
+ endif
+endif
+
+ifeq ($(PORTNAME), i386_solaris)
+ CFLAGS+= -fPIC
+endif
+
+MODNAME = soundex
+
+MODULE = $(MODNAME)$(DLSUFFIX)
+
+all: module sql
+
+module: $(MODULE)
+
+sql: $(MODNAME).sql
+
+install: $(MODULE)
+ cp -p $(MODULE) $(LIBDIR)/modules
+ cd $(LIBDIR)/modules; strip $(MODULE)
+
+%.sql: %.sql.in
+ sed "s|MODULE_PATHNAME|$(LIBDIR)/modules/$(MODULE)|" < $< > $@
+
+.SUFFIXES: $(DLSUFFIX)
+
+%$(DLSUFFIX): %.c
+ $(CC) $(CFLAGS) -shared -o $@ $<
+
+depend dep:
+ $(CC) -MM $(INCLUDE_OPT) *.c >depend
+
+clean:
+ rm -f $(MODULE) $(MODNAME).sql
+
+ifeq (depend,$(wildcard depend))
+include depend
+endif
diff --git a/contrib/soundex/soundex.sql.in b/contrib/soundex/soundex.sql.in
new file mode 100644
index 00000000000..89b9fa5222a
--- /dev/null
+++ b/contrib/soundex/soundex.sql.in
@@ -0,0 +1,57 @@
+--------------- soundex.sql:
+
+CREATE FUNCTION text_soundex(text) RETURNS text
+ AS '_OBJWD_/soundex.so' LANGUAGE 'c';
+
+SELECT text_soundex('hello world!');
+
+CREATE TABLE s (nm text)\g
+
+insert into s values ('john')\g
+insert into s values ('joan')\g
+insert into s values ('wobbly')\g
+
+select * from s
+where text_soundex(nm) = text_soundex('john')\g
+
+select nm from s a, s b
+where text_soundex(a.nm) = text_soundex(b.nm)
+and a.oid <> b.oid\g
+
+CREATE FUNCTION text_sx_eq(text, text) RETURNS bool AS
+'select text_soundex($1) = text_soundex($2)'
+LANGUAGE 'sql'\g
+
+CREATE FUNCTION text_sx_lt(text,text) RETURNS bool AS
+'select text_soundex($1) < text_soundex($2)'
+LANGUAGE 'sql'\g
+
+CREATE FUNCTION text_sx_gt(text,text) RETURNS bool AS
+'select text_soundex($1) > text_soundex($2)'
+LANGUAGE 'sql';
+
+CREATE FUNCTION text_sx_le(text,text) RETURNS bool AS
+'select text_soundex($1) <= text_soundex($2)'
+LANGUAGE 'sql';
+
+CREATE FUNCTION text_sx_ge(text,text) RETURNS bool AS
+'select text_soundex($1) >= text_soundex($2)'
+LANGUAGE 'sql';
+
+CREATE FUNCTION text_sx_ne(text,text) RETURNS bool AS
+'select text_soundex($1) <> text_soundex($2)'
+LANGUAGE 'sql';
+
+DROP OPERATOR #= (text,text)\g
+
+CREATE OPERATOR #= (leftarg=text, rightarg=text, procedure=text_sx_eq,
+commutator=text_sx_eq)\g
+
+SELECT *
+FROM s
+WHERE text_sx_eq(nm,'john')\g
+
+SELECT *
+from s
+where s.nm #= 'john';
+