--
-- Copyright (c) 1994, Regents of the University of California
--
--- $Id: complex.source,v 1.3 1998/02/28 23:37:09 scrappy Exp $
+-- $Id: complex.source,v 1.4 1998/03/01 04:52:59 scrappy Exp $
--
---------------------------------------------------------------------------
-----------------------------
-- Assume the user defined functions are in _OBJWD_/complex.so
--- Look at $PWD/C-code/complex.c for the source.
+-- Look at $PWD/complex.c for the source.
-- the input function 'complex_in' takes a null-terminated string (the
-- textual representation of the type) and turns it into the internal
-- arguments.)
-----------------------------
--- first, define a function complex_add (also in C-code/complex.c)
+-- first, define a function complex_add (also in complex.c)
CREATE FUNCTION complex_add(complex, complex)
RETURNS complex
AS '_OBJWD_/complex.so'
WHERE amname = 'btree' and opcname = 'complex_abs_ops'
and c.oprname = '>';
-DROP table complex_ops_tmp;
-
--
CREATE FUNCTION complex_abs_cmp(complex, complex) RETURNS int4
AS '_OBJWD_/complex.so' LANGUAGE 'c';
SELECT * from test_complex where a < '(56.0,-22.5)';
SELECT * from test_complex where a > '(56.0,-22.5)';
+DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
+ = (
+ SELECT am.oid, opcl.oid, c.opoid, 1
+ FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
+ WHERE amname = 'btree' and opcname = 'complex_abs_ops'
+ and c.oprname = '<');
+
+DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
+ = (
+ SELECT am.oid, opcl.oid, c.opoid, 2
+ FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
+ WHERE amname = 'btree' and opcname = 'complex_abs_ops'
+ and c.oprname = '<=');
+
+DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
+ = (
+ SELECT am.oid, opcl.oid, c.opoid, 3
+ FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
+ WHERE amname = 'btree' and opcname = 'complex_abs_ops'
+ and c.oprname = '=');
+
+DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
+ = (
+ SELECT am.oid, opcl.oid, c.opoid, 4
+ FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
+ WHERE amname = 'btree' and opcname = 'complex_abs_ops'
+ and c.oprname = '>=');
+
+DELETE FROM pg_amop where (amopid, amopclaid, amopopr, amopstrategy)
+ = (
+ SELECT am.oid, opcl.oid, c.opoid, 5
+ FROM pg_am am, pg_opclass opcl, complex_ops_tmp c
+ WHERE amname = 'btree' and opcname = 'complex_abs_ops'
+ and c.oprname = '>');
+
+DELETE FROM pg_amproc where (amid, amopclaid, amproc, amprocnum)
+ = (
+ SELECT am.oid, opcl.oid, pro.oid, 1
+ FROM pg_am am, pg_opclass opcl, pg_proc pro
+ WHERE amname = 'btree' and opcname = 'complex_abs_ops'
+ and proname = 'complex_abs_cmp');
+
+DELETE FROM pg_opclass WHERE opcname = 'complex_abs_ops';
+
DROP FUNCTION complex_in(opaque);
DROP FUNCTION complex_out(opaque);
DROP FUNCTION complex_add(complex, complex);
DROP OPERATOR > (complex, complex);
DROP AGGREGATE complex_sum complex;
DROP TYPE complex;
-DROP TABLE test_complex;
+DROP TABLE test_complex, complex_ops_tmp;