2
0
mirror of https://git.postgresql.org/git/postgresql.git synced 2024-12-21 08:29:39 +08:00
postgresql/contrib/isbn_issn/isbn_issn.sql.in

270 lines
4.9 KiB
MySQL
Raw Normal View History

2000-06-16 03:05:22 +08:00
--
-- PostgreSQL code for ISSNs.
--
-- $PostgreSQL: pgsql/contrib/isbn_issn/isbn_issn.sql.in,v 1.11 2005/01/29 22:35:02 tgl Exp $
2000-06-16 03:05:22 +08:00
--
-- Adjust this setting to control where the objects get created.
SET search_path = public;
2000-06-16 03:05:22 +08:00
--
-- Input and output functions and the type itself:
--
CREATE FUNCTION issn_in(cstring)
RETURNS issn
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE FUNCTION issn_out(issn)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE TYPE issn (
INTERNALLENGTH = 16,
EXTERNALLENGTH = 9,
INPUT = issn_in,
OUTPUT = issn_out
2000-06-16 03:05:22 +08:00
);
COMMENT ON TYPE issn
is 'International Standard Serial Number';
2000-06-16 03:05:22 +08:00
--
-- The various boolean tests:
--
CREATE FUNCTION issn_lt(issn, issn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION issn_le(issn, issn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION issn_eq(issn, issn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION issn_ge(issn, issn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION issn_gt(issn, issn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION issn_ne(issn, issn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
--
-- 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
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR <= (
LEFTARG = issn,
RIGHTARG = issn,
-- NEGATOR = >,
PROCEDURE = issn_le
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR = (
LEFTARG = issn,
RIGHTARG = issn,
COMMUTATOR = =,
-- NEGATOR = <>,
PROCEDURE = issn_eq
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR >= (
LEFTARG = issn,
RIGHTARG = issn,
NEGATOR = <,
PROCEDURE = issn_ge
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR > (
LEFTARG = issn,
RIGHTARG = issn,
NEGATOR = <=,
PROCEDURE = issn_gt
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR <> (
LEFTARG = issn,
RIGHTARG = issn,
NEGATOR = =,
PROCEDURE = issn_ne
2000-06-16 03:05:22 +08:00
);
2003-06-28 08:36:40 +08:00
-- Register 'issn' comparison function
CREATE FUNCTION issn_cmp(issn, issn)
RETURNS integer
AS '$libdir/isbn_issn'
LANGUAGE c STRICT;
2003-06-28 08:36:40 +08:00
-- 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);
------------------------------------------------------------------------
2000-06-16 03:05:22 +08:00
--
2003-06-28 08:36:40 +08:00
-- Same code for ISBN
2000-06-16 03:05:22 +08:00
--
-- Input and output functions and the type itself:
--
CREATE FUNCTION isbn_in(cstring)
RETURNS isbn
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE FUNCTION isbn_out(isbn)
RETURNS cstring
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
CREATE TYPE isbn (
INTERNALLENGTH = 16,
EXTERNALLENGTH = 13,
INPUT = isbn_in,
OUTPUT = isbn_out
2000-06-16 03:05:22 +08:00
);
COMMENT ON TYPE isbn IS 'International Standard Book Number';
2000-06-16 03:05:22 +08:00
--
-- The various boolean tests:
--
CREATE FUNCTION isbn_lt(isbn, isbn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION isbn_le(isbn, isbn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION isbn_eq(isbn, isbn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION isbn_ge(isbn, isbn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION isbn_gt(isbn, isbn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
CREATE FUNCTION isbn_ne(isbn, isbn)
RETURNS bool
AS 'MODULE_PATHNAME'
LANGUAGE C STRICT;
2000-06-16 03:05:22 +08:00
--
-- 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
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR <= (
LEFTARG = isbn,
RIGHTARG = isbn,
-- NEGATOR = >,
PROCEDURE = isbn_le
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR = (
LEFTARG = isbn,
RIGHTARG = isbn,
COMMUTATOR = =,
-- NEGATOR = <>,
PROCEDURE = isbn_eq
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR >= (
LEFTARG = isbn,
RIGHTARG = isbn,
NEGATOR = <,
PROCEDURE = isbn_ge
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR > (
LEFTARG = isbn,
RIGHTARG = isbn,
NEGATOR = <=,
PROCEDURE = isbn_gt
2000-06-16 03:05:22 +08:00
);
CREATE OPERATOR <> (
LEFTARG = isbn,
RIGHTARG = isbn,
NEGATOR = =,
PROCEDURE = isbn_ne
2000-06-16 03:05:22 +08:00
);
-- Register 'isbn' comparison function
CREATE FUNCTION isbn_cmp(isbn, isbn)
RETURNS integer
AS '$libdir/isbn_issn'
LANGUAGE c STRICT;
-- 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);