postgresql/contrib/isbn_issn/isbn_issn.sql.in
Tom Lane 65b6868b13 Replace ad-hoc insertions into pg_opclass and friends with CREATE
OPERATOR CLASS commands.  Further tweaking of documentation for same.
2002-07-30 17:34:37 +00:00

282 lines
5.1 KiB
MySQL

--
-- PostgreSQL code for ISSNs.
--
-- $Id: isbn_issn.sql.in,v 1.5 2002/07/30 17:34:37 tgl Exp $
--
-- Adjust this setting to control where the objects get created.
SET search_path = public;
--
-- Input and output functions and the type itself:
--
create function issn_in(opaque)
returns opaque
as 'MODULE_PATHNAME'
language 'c';
create function issn_out(opaque)
returns opaque
as 'MODULE_PATHNAME'
language 'c';
create type issn (
internallength = 16,
externallength = 9,
input = issn_in,
output = issn_out
);
comment on type issn
is 'International Standard Serial Number';
--
-- The various boolean tests:
--
create function issn_lt(issn, issn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function issn_le(issn, issn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function issn_eq(issn, issn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function issn_ge(issn, issn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function issn_gt(issn, issn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function issn_ne(issn, issn)
returns bool
as 'MODULE_PATHNAME'
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 = issn,
rightarg = issn,
-- negator = >=,
procedure = issn_lt
);
create operator <= (
leftarg = issn,
rightarg = issn,
-- negator = >,
procedure = issn_le
);
create operator = (
leftarg = issn,
rightarg = issn,
commutator = =,
-- negator = <>,
procedure = issn_eq
);
create operator >= (
leftarg = issn,
rightarg = issn,
negator = <,
procedure = issn_ge
);
create operator > (
leftarg = issn,
rightarg = issn,
negator = <=,
procedure = issn_gt
);
create operator <> (
leftarg = issn,
rightarg = issn,
negator = =,
procedure = issn_ne
);
--
-- eof
--
--
-- PostgreSQL code for ISBNs.
--
-- $Id: isbn_issn.sql.in,v 1.5 2002/07/30 17:34:37 tgl Exp $
--
--
-- Input and output functions and the type itself:
--
create function isbn_in(opaque)
returns opaque
as 'MODULE_PATHNAME'
language 'c';
create function isbn_out(opaque)
returns opaque
as 'MODULE_PATHNAME'
language 'c';
create type isbn (
internallength = 16,
externallength = 13,
input = isbn_in,
output = isbn_out
);
comment on type isbn
is 'International Standard Book Number';
--
-- The various boolean tests:
--
create function isbn_lt(isbn, isbn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function isbn_le(isbn, isbn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function isbn_eq(isbn, isbn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function isbn_ge(isbn, isbn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function isbn_gt(isbn, isbn)
returns bool
as 'MODULE_PATHNAME'
language 'c';
create function isbn_ne(isbn, isbn)
returns bool
as 'MODULE_PATHNAME'
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 = isbn,
rightarg = isbn,
-- negator = >=,
procedure = isbn_lt
);
create operator <= (
leftarg = isbn,
rightarg = isbn,
-- negator = >,
procedure = isbn_le
);
create operator = (
leftarg = isbn,
rightarg = isbn,
commutator = =,
-- negator = <>,
procedure = isbn_eq
);
create operator >= (
leftarg = isbn,
rightarg = isbn,
negator = <,
procedure = isbn_ge
);
create operator > (
leftarg = isbn,
rightarg = isbn,
negator = <=,
procedure = isbn_gt
);
create operator <> (
leftarg = isbn,
rightarg = isbn,
negator = =,
procedure = isbn_ne
);
-- Register 'isbn' comparison function
create function isbn_cmp(isbn, isbn)
returns integer
as '$libdir/isbn_issn'
language c;
-- Register 'issn' comparison function
create function issn_cmp(issn, issn)
returns integer
as '$libdir/isbn_issn'
language c;
-------------------------------------------------
-- Create default operator class for 'isbn' --
-- Needed to create index or primary key --
-------------------------------------------------
CREATE OPERATOR CLASS isbn_ops
DEFAULT FOR TYPE isbn USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 isbn_cmp(isbn, isbn);
-------------------------------------------------
-- Create default operator class for 'issn' --
-- Needed to create index or primary key --
-------------------------------------------------
CREATE OPERATOR CLASS issn_ops
DEFAULT FOR TYPE issn USING btree AS
OPERATOR 1 < ,
OPERATOR 2 <= ,
OPERATOR 3 = ,
OPERATOR 4 >= ,
OPERATOR 5 > ,
FUNCTION 1 issn_cmp(issn, issn);
--
-- eof
--