pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #13442: ISBN doesn't always roundtrip with text
26+ messages / 9 participants
[nested] [flat]
* BUG #13442: ISBN doesn't always roundtrip with text
@ 2015-06-14 15:59 bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 26+ messages in thread
From: bz@mailinator.com @ 2015-06-14 15:59 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 13442
Logged by: B.Z
Email address: bz@mailinator.com
PostgreSQL version: 9.4.4
Operating system: Linux think 4.0.0-1-amd64 #1 SMP Debian 4.0.2-1 (2
Description:
I have a table containing ISBNs stored as the isbn type provided by the isn
extension. In certain cases an ISBN in ISBN10 form is considered unequal to
the same ISBN in ISBN13 form.
Assuming the isn extension is installed:
CREATE TEMP TABLE t(i isbn);
INSERT INTO t VALUES('9791020902573');
SELECT * FROM t WHERE i = '9791020902573'; -- Returns 10-209-0257-4
SELECT * FROM t WHERE i = '10-209-0257-4'; -- Returns 0 rows
SELECT '9791020902573'::isbn = '10-209-0257-4'::isbn; -- Returns f
Other examples of ISBNs with this behavior:
select isbn from isbns where isbn::isbn != isbn::isbn::text::isbn;
isbn
10-91986-01-0
10-91414-02-5
975891300-X
598687008-5
904072556-X
10-209-0257-4
10-209-0014-8
960838204-1
10-91447-03-9
963208937-5
10-209-0011-3
975297291-8
957849470-X
157607283-5
10-93509-00-7
10-209-0014-8
10-209-0273-6
975574374-X
979984511-4
953173635-9
853390230-1
963930301-1
10-223-0179-9
10-209-0141-1
10-209-0041-5
960218202-4
598340069-X
10-91600-01-5
598340069-X
(29 rows)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
@ 2015-06-15 17:26 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-15 22:47 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Peter Geoghegan <pg@heroku.com>
0 siblings, 2 replies; 26+ messages in thread
From: Tom Lane @ 2015-06-15 17:26 UTC (permalink / raw)
To: bz@mailinator.com; +Cc: pgsql-bugs
bz@mailinator.com writes:
> I have a table containing ISBNs stored as the isbn type provided by the isn
> extension. In certain cases an ISBN in ISBN10 form is considered unequal to
> the same ISBN in ISBN13 form.
I poked at this a little bit. I think the issue may be that this bit
at line 832 in isn.c:
case ISBN:
memcpy(buf, "978", 3);
supposes that all ISBNs should have prefix 978, whereas your example is
using prefix 979, which seems to be also valid according to code a few
lines above. I don't know enough about the whole ISBN/EAN mess to
understand what this should be doing instead, though.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-06-15 18:34 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 26+ messages in thread
From: Fabien COELHO @ 2015-06-15 18:34 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
>> I have a table containing ISBNs stored as the isbn type provided by the isn
>> extension. In certain cases an ISBN in ISBN10 form is considered unequal to
>> the same ISBN in ISBN13 form.
>
> I poked at this a little bit. I think the issue may be that this bit
> at line 832 in isn.c:
>
> case ISBN:
> memcpy(buf, "978", 3);
>
> supposes that all ISBNs should have prefix 978, whereas your example is
> using prefix 979, which seems to be also valid according to code a few
> lines above. I don't know enough about the whole ISBN/EAN mess to
> understand what this should be doing instead, though.
Hmmm. ISBN-10 -> ISBN-13 is really just adding "978" in front, so there is
no casted ISBN-10 number starting with 979. ISTM that "979" is just a
recorded prefix for books, just as "978", for ISBN-13. AFAICR the prefix
was chosen so that the checksum digit can be kept in the conversion.
SELECT '9791020902573'::isbn = '10-209-0257-4'::isbn; -- Returns f
Indeed, but this one should return true:
SELECT '9781020902574'::isbn = '10-209-0257-4'::isbn;
So I would say there is no bug as the number are indeed different, or that
I missed something.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-06-16 03:35 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 1 reply; 26+ messages in thread
From: Tom Lane @ 2015-06-16 03:35 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: pgsql-bugs
Fabien COELHO <coelho@cri.ensmp.fr> writes:
>>> I have a table containing ISBNs stored as the isbn type provided by the isn
>>> extension. In certain cases an ISBN in ISBN10 form is considered unequal to
>>> the same ISBN in ISBN13 form.
> So I would say there is no bug as the number are indeed different, or that
> I missed something.
I think this definitely indicates a bug:
regression=# select '9791020902573'::isbn;
isbn
---------------
10-209-0257-4
(1 row)
regression=# select '10-209-0257-4'::isbn;
isbn
---------------
1-02-090257-4
(1 row)
I don't mind if '9791020902573' gets converted to something canonical,
but surely the canonical value ought to reproduce without further change.
Furthermore,
regression=# select '9791020902573'::isbn = '10-209-0257-4'::isbn;
?column?
----------
f
(1 row)
so apparently the canonicalization conversion wasn't right to begin with.
I have no idea which of these forms should be considered valid or
canonical, but surely the two behaviors exhibited above are wrong.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-06-16 05:37 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 06:09 ` Re: BUG #13442: ISBN doesn't always roundtrip with text David G. Johnston <david.g.johnston@gmail.com>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 2 replies; 26+ messages in thread
From: Fabien COELHO @ 2015-06-16 05:37 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
> I think this definitely indicates a bug:
>
> regression=# select '9791020902573'::isbn;
> isbn
> ---------------
> 10-209-0257-4
> (1 row)
Yes, indeed, this one is definitely a bug.
> regression=# select '9791020902573'::isbn = '10-209-0257-4'::isbn;
> ?column?
> ----------
> f
> (1 row)
>
> so apparently the canonicalization conversion wasn't right to begin with.
I still do not get it, "False" is expected on this last one, as this is
not the same book.
> I have no idea which of these forms should be considered valid or
> canonical, but surely the two behaviors exhibited above are wrong.
I think that it is only the first one, i.e. converting the ISBN13 code
beginning with 979 to a ISBN10 should have raised an exception.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-06-16 06:09 ` David G. Johnston <david.g.johnston@gmail.com>
2015-06-16 08:05 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
1 sibling, 1 reply; 26+ messages in thread
From: David G. Johnston @ 2015-06-16 06:09 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; bz@mailinator.com <bz@mailinator.com>; pgsql-bugs
On Tuesday, June 16, 2015, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
>
> I think this definitely indicates a bug:
>>
>> regression=# select '9791020902573'::isbn;
>> isbn
>> ---------------
>> 10-209-0257-4
>> (1 row)
>>
>
> Yes, indeed, this one is definitely a bug.
>
> regression=# select '9791020902573'::isbn = '10-209-0257-4'::isbn;
>> ?column?
>> ----------
>> f
>> (1 row)
>>
>> so apparently the canonicalization conversion wasn't right to begin with.
>>
>
> I still do not get it, "False" is expected on this last one, as this is
> not the same book.
> I have no idea which of these forms should be considered valid or
>> canonical, but surely the two behaviors exhibited above are wrong.
>>
>
> I think that it is only the first one, i.e. converting the ISBN13 code
> beginning with 979 to a ISBN10 should have raised an exception.
>
>
There is only one problem/bug (hopefully) but it is evidenced by the fact
that the two queries provided contradict each other. It is basically a
different form of proof. You know the first query is wrong using external
knowledge but Tom has shown that a bug exists using strictly knowledge
local to the system. Without the external knowledge one cannot say which
alternative is correct but one must be incorrect.
Fixing the first query to become an error brings the system basic into
internal consistency since that result is congruous with the second query.
And is externally affirmed to be the correct outcome (I trust...).
Making the second query return true makes the system internally consistent
too...but doesn't actually provide the correct answer (again, I trust)
David J.
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 06:09 ` Re: BUG #13442: ISBN doesn't always roundtrip with text David G. Johnston <david.g.johnston@gmail.com>
@ 2015-06-16 08:05 ` Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 0 replies; 26+ messages in thread
From: Fabien COELHO @ 2015-06-16 08:05 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; bz@mailinator.com <bz@mailinator.com>; pgsql-bugs
>> regression=# select '9791020902573'::isbn = '10-209-0257-4'::isbn;
>> f
>> beginning with 979 to a ISBN10 should have raised an exception.
> Making the second query return true makes the system internally consistent
> too...but doesn't actually provide the correct answer (again, I trust)
Yes.
On third thoughs, the above query should raise an exception because the
cast is illegal, 979* is not an ISBN, so the answer is neither true nor
false. The query should be simply written to use the larger type and not
cast to the subtype.
SELECT EAN13 '9791234567896' = ISBN '123456789X'; -- False
SELECT EAN13 '9781234567897' = ISBN '123456789X'; -- True
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-06-20 07:04 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
1 sibling, 1 reply; 26+ messages in thread
From: Fabien COELHO @ 2015-06-20 07:04 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
>> I think this definitely indicates a bug:
>>
>> regression=# select '9791020902573'::isbn;
>> isbn
>> ---------------
>> 10-209-0257-4
>> (1 row)
>
> Yes, indeed, this one is definitely a bug.
Attached patch makes isn to distinguish when needed between ISBN and
ISBN13. ISBN is the legacy ISBN10 number which is part of ISBN13, but not
all ISBN13 numbers are ISBN.
The initial version was confusing both types, leading to accept valid
ISBN13 number as valid ISBN(10) number although they use the 979 prefix,
hence the reported issues.
The patch also adds some tests.
There is no clear upgrade path from 1.0 to 2.0, as the ISBN "in" function
is changed, as well as some casts. I'm not sure of a safe way to upgrade,
because the initial version was accepting invalid ISBN which would now be
rejected, thus some store data may be considered corrupted in a database.
On the other hand, probably few people would use a legacy ISBN type and
put ISBN13 number in them, hopefully? Hmmm...
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
isn-fix-1.patch (text/x-diff, 87.9K) download
diff --git a/contrib/isn/Makefile b/contrib/isn/Makefile
index 75c07a8..72be058 100644
--- a/contrib/isn/Makefile
+++ b/contrib/isn/Makefile
@@ -3,9 +3,11 @@
MODULES = isn
EXTENSION = isn
-DATA = isn--1.0.sql isn--unpackaged--1.0.sql
+DATA = isn--2.0.sql isn--unpackaged--1.0.sql
PGFILEDESC = "isn - data types for international product numbering standards"
+REGRESS = isn
+
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/isn/expected/isn.out b/contrib/isn/expected/isn.out
new file mode 100644
index 0000000..954f62b
--- /dev/null
+++ b/contrib/isn/expected/isn.out
@@ -0,0 +1,229 @@
+--
+-- Test ISN extension
+--
+CREATE EXTENSION isn;
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+ ean13 | ean13 | ean13 | ean13 | ean13 | ean13
+-------------------+-------------------+-----------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 979-0-1234-5678-5 | 979-123456789-6 | 977-1234-567-89-8 | 012-345678901-2 | 123-456789012-8
+(1 row)
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+ isbn | isbn | isbn | isbn
+---------------+---------------+---------------+---------------
+ 0-12-345678-9 | 1-234-56789-X | 0-12-345678-9 | 0-12-345678-9
+(1 row)
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+ isbn13 | isbn13 | isbn13 | isbn13
+-------------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 978-1-234-56789-7 | 979-123456789-6 | 979-123456789-6
+(1 row)
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+ ismn | ismn | ismn | ismn
+---------------+---------------+---------------+---------------
+ M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5
+(1 row)
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+ ismn13 | ismn13 | ismn13
+-------------------+-------------------+-------------------
+ 979-0-1234-5678-5 | 979-0-1234-5678-5 | 979-0-1234-5678-5
+(1 row)
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+ issn | issn
+-----------+-----------
+ 1234-5679 | 1234-5679
+(1 row)
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+ issn13 | issn13 | issn13 | issn13
+-------------------+-------------------+-------------------+-------------------
+ 977-1234-567-00-3 | 977-1234-567-00-3 | 977-1234-567-89-8 | 977-1234-567-89-8
+(1 row)
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+ upc | upc
+--------------+--------------
+ 123456789012 | 123456789012
+(1 row)
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+ERROR: invalid check digit for ISBN number: "1234567890", should be X
+LINE 1: SELECT '1234567890'::ISBN;
+ ^
+SELECT 'M123456780'::ISMN;
+ERROR: invalid check digit for ISMN number: "M123456780", should be 5
+LINE 1: SELECT 'M123456780'::ISMN;
+ ^
+SELECT '12345670'::ISSN;
+ERROR: invalid check digit for ISSN number: "12345670", should be 9
+LINE 1: SELECT '12345670'::ISSN;
+ ^
+SELECT '9780123456780'::ISBN;
+ERROR: invalid check digit for ISBN number: "9780123456780", should be 6
+LINE 1: SELECT '9780123456780'::ISBN;
+ ^
+SELECT '9791234567890'::ISBN13;
+ERROR: invalid check digit for ISBN13 number: "9791234567890", should be 6
+LINE 1: SELECT '9791234567890'::ISBN13;
+ ^
+SELECT '0123456789010'::UPC;
+ERROR: invalid check digit for UPC number: "0123456789010", should be 2
+LINE 1: SELECT '0123456789010'::UPC;
+ ^
+SELECT '1234567890120'::EAN13;
+ERROR: invalid check digit for EAN13 number: "1234567890120", should be 8
+LINE 1: SELECT '1234567890120'::EAN13;
+ ^
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+ERROR: cannot cast ISMN to ISBN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN;
+ ^
+SELECT '9791234567896'::ISBN; -- not an old book
+ERROR: cannot cast ISBN13 to ISBN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISBN;
+ ^
+SELECT '9771234567898'::ISBN; -- not a book
+ERROR: cannot cast ISSN to ISBN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN;
+ ^
+SELECT '9791234567896'::ISBN13::ISBN; -- not a an old book
+ERROR: cannot cast EAN13(ISBN13) to ISBN for number: "9791234567896"
+SELECT '9791234567896'::EAN13::ISBN; -- not a an old book
+ERROR: cannot cast EAN13(ISBN13) to ISBN for number: "9791234567896"
+SELECT '0123456789012'::ISBN; -- not a book
+ERROR: cannot cast UPC to ISBN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN;
+ ^
+SELECT '9790123456785'::ISBN13; -- not a book
+ERROR: cannot cast ISMN to ISBN13 for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN13;
+ ^
+SELECT '9771234567898'::ISBN13; -- not a book
+ERROR: cannot cast ISSN to ISBN13 for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN13;
+ ^
+SELECT '9771234567898'::EAN13::ISBN13; -- not a book
+ERROR: cannot cast EAN13(ISSN) to ISBN13 for number: "9771234567898"
+SELECT '0123456789012'::ISBN13; -- not a book
+ERROR: cannot cast UPC to ISBN13 for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN13;
+ ^
+SELECT '9780123456786'::ISMN; -- not music
+ERROR: cannot cast ISBN to ISMN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISMN;
+ ^
+SELECT '9771234567898'::ISMN; -- not music
+ERROR: cannot cast ISSN to ISMN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISMN;
+ ^
+SELECT '9791234567896'::ISMN; -- not music
+ERROR: cannot cast ISBN13 to ISMN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISMN;
+ ^
+SELECT '0123456789012'::ISMN; -- not music
+ERROR: cannot cast UPC to ISMN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISMN;
+ ^
+SELECT '9780123456786'::ISSN; -- not serial
+ERROR: cannot cast ISBN to ISSN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISSN;
+ ^
+SELECT '9790123456785'::ISSN; -- not serial
+ERROR: cannot cast ISMN to ISSN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISSN;
+ ^
+SELECT '9791234567896'::ISSN; -- not serial
+ERROR: cannot cast ISBN13 to ISSN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISSN;
+ ^
+SELECT '0123456789012'::ISSN; -- not serial
+ERROR: cannot cast UPC to ISSN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISSN;
+ ^
+SELECT '9780123456786'::UPC; -- not a product
+ERROR: cannot cast ISBN to UPC for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::UPC;
+ ^
+SELECT '9771234567898'::UPC; -- not a product
+ERROR: cannot cast ISSN to UPC for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::UPC;
+ ^
+SELECT '9790123456785'::UPC; -- not a product
+ERROR: cannot cast ISMN to UPC for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::UPC;
+ ^
+SELECT '9791234567896'::UPC; -- not a product
+ERROR: cannot cast ISBN13 to UPC for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::UPC;
+ ^
+SELECT '0123456789012'::UPC; -- not a product
+ upc
+--------------
+ 123456789012
+(1 row)
+
+SELECT 'postgresql...'::EAN13;
+ERROR: invalid input syntax for EAN13 number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::EAN13;
+ ^
+SELECT 'postgresql...'::ISBN;
+ERROR: invalid input syntax for ISBN number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::ISBN;
+ ^
+SELECT 9780123456786::EAN13;
+ERROR: cannot cast type bigint to ean13
+LINE 1: SELECT 9780123456786::EAN13;
+ ^
+SELECT 9780123456786::ISBN;
+ERROR: cannot cast type bigint to isbn
+LINE 1: SELECT 9780123456786::ISBN;
+ ^
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+ ok | ok | nope
+----+----+------
+ t | t | t
+(1 row)
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
diff --git a/contrib/isn/isn--2.0.sql b/contrib/isn/isn--2.0.sql
new file mode 100644
index 0000000..93f35c5
--- /dev/null
+++ b/contrib/isn/isn--2.0.sql
@@ -0,0 +1,3200 @@
+/* contrib/isn/isn--1.0.sql */
+
+-- complain if script is sourced in psql, rather than via CREATE EXTENSION
+\echo Use "CREATE EXTENSION isn" to load this file. \quit
+
+-- Example:
+-- create table test ( id isbn );
+-- insert into test values('978-0-393-04002-9');
+--
+-- select isbn('978-0-393-04002-9');
+-- select isbn13('0-901690-54-6');
+--
+
+--
+-- Input and output functions and data types:
+--
+---------------------------------------------------
+CREATE FUNCTION ean13_in(cstring)
+ RETURNS ean13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(ean13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE ean13 (
+ INPUT = ean13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE ean13
+ IS 'International European Article Number (EAN13)';
+
+CREATE FUNCTION isbn13_in(cstring)
+ RETURNS isbn13
+ AS 'MODULE_PATHNAME', 'isbn13_in'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(isbn13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE isbn13 (
+ INPUT = isbn13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE isbn13
+ IS 'International Standard Book Number 13 (ISBN13)';
+
+CREATE FUNCTION ismn13_in(cstring)
+ RETURNS ismn13
+ AS 'MODULE_PATHNAME', 'ismn_in'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(ismn13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE ismn13 (
+ INPUT = ismn13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE ismn13
+ IS 'International Standard Music Number 13 (ISMN13)';
+
+CREATE FUNCTION issn13_in(cstring)
+ RETURNS issn13
+ AS 'MODULE_PATHNAME', 'issn_in'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(issn13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE issn13 (
+ INPUT = issn13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE issn13
+ IS 'International Standard Serial Number 13 (ISSN13)';
+
+-- Short format:
+
+CREATE FUNCTION isbn_in(cstring)
+ RETURNS isbn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(isbn)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE isbn (
+ INPUT = isbn_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE isbn
+ IS 'International Standard Book Number (ISBN)';
+
+CREATE FUNCTION ismn_in(cstring)
+ RETURNS ismn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(ismn)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE ismn (
+ INPUT = ismn_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE ismn
+ IS 'International Standard Music Number (ISMN)';
+
+CREATE FUNCTION issn_in(cstring)
+ RETURNS issn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(issn)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE issn (
+ INPUT = issn_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE issn
+ IS 'International Standard Serial Number (ISSN)';
+
+CREATE FUNCTION upc_in(cstring)
+ RETURNS upc
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(upc)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE upc (
+ INPUT = upc_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE upc
+ IS 'Universal Product Code (UPC)';
+
+--
+-- Operator functions:
+--
+---------------------------------------------------
+-- EAN13:
+CREATE FUNCTION isnlt(ean13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, issn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, issn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, issn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, issn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, issn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, issn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, isbn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, isbn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, isbn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, isbn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, isbn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, isbn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, ismn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, ismn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, ismn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, ismn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, ismn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, ismn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, issn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, issn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, issn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, issn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, issn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, issn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, upc)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, upc)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, upc)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, upc)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, upc)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, upc)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISBN13:
+CREATE FUNCTION isnlt(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISBN:
+CREATE FUNCTION isnlt(isbn, isbn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn, isbn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn, isbn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn, isbn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn, isbn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn, isbn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISMN13:
+CREATE FUNCTION isnlt(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISMN:
+CREATE FUNCTION isnlt(ismn, ismn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn, ismn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn, ismn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn, ismn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn, ismn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn, ismn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISSN13:
+CREATE FUNCTION isnlt(issn13, issn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn13, issn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn13, issn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn13, issn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn13, issn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn13, issn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn13, issn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn13, issn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn13, issn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn13, issn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn13, issn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn13, issn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISSN:
+CREATE FUNCTION isnlt(issn, issn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn, issn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn, issn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn, issn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn, issn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn, issn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn, issn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn, issn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn, issn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn, issn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn, issn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn, issn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- UPC:
+CREATE FUNCTION isnlt(upc, upc)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(upc, upc)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(upc, upc)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(upc, upc)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(upc, upc)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(upc, upc)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(upc, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(upc, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(upc, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(upc, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(upc, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(upc, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+--
+-- Now the operators:
+--
+
+--
+-- EAN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISBN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISBN operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISMN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISMN operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISSN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISSN operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- UPC operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- Operator families for the various operator classes:
+--
+---------------------------------------------------
+
+CREATE OPERATOR FAMILY isn_ops USING btree;
+CREATE OPERATOR FAMILY isn_ops USING hash;
+
+--
+-- Operator classes:
+--
+---------------------------------------------------
+-- EAN13:
+CREATE FUNCTION btean13cmp(ean13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ean13_ops DEFAULT
+ FOR TYPE ean13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btean13cmp(ean13, ean13);
+
+CREATE FUNCTION hashean13(ean13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal' IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ean13_ops DEFAULT
+ FOR TYPE ean13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashean13(ean13);
+
+-- EAN13 vs other types:
+CREATE FUNCTION btean13cmp(ean13, isbn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, ismn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, issn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, isbn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, ismn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, issn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, upc)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (ean13, isbn13),
+ OPERATOR 1 < (ean13, ismn13),
+ OPERATOR 1 < (ean13, issn13),
+ OPERATOR 1 < (ean13, isbn),
+ OPERATOR 1 < (ean13, ismn),
+ OPERATOR 1 < (ean13, issn),
+ OPERATOR 1 < (ean13, upc),
+ OPERATOR 2 <= (ean13, isbn13),
+ OPERATOR 2 <= (ean13, ismn13),
+ OPERATOR 2 <= (ean13, issn13),
+ OPERATOR 2 <= (ean13, isbn),
+ OPERATOR 2 <= (ean13, ismn),
+ OPERATOR 2 <= (ean13, issn),
+ OPERATOR 2 <= (ean13, upc),
+ OPERATOR 3 = (ean13, isbn13),
+ OPERATOR 3 = (ean13, ismn13),
+ OPERATOR 3 = (ean13, issn13),
+ OPERATOR 3 = (ean13, isbn),
+ OPERATOR 3 = (ean13, ismn),
+ OPERATOR 3 = (ean13, issn),
+ OPERATOR 3 = (ean13, upc),
+ OPERATOR 4 >= (ean13, isbn13),
+ OPERATOR 4 >= (ean13, ismn13),
+ OPERATOR 4 >= (ean13, issn13),
+ OPERATOR 4 >= (ean13, isbn),
+ OPERATOR 4 >= (ean13, ismn),
+ OPERATOR 4 >= (ean13, issn),
+ OPERATOR 4 >= (ean13, upc),
+ OPERATOR 5 > (ean13, isbn13),
+ OPERATOR 5 > (ean13, ismn13),
+ OPERATOR 5 > (ean13, issn13),
+ OPERATOR 5 > (ean13, isbn),
+ OPERATOR 5 > (ean13, ismn),
+ OPERATOR 5 > (ean13, issn),
+ OPERATOR 5 > (ean13, upc),
+ FUNCTION 1 btean13cmp(ean13, isbn13),
+ FUNCTION 1 btean13cmp(ean13, ismn13),
+ FUNCTION 1 btean13cmp(ean13, issn13),
+ FUNCTION 1 btean13cmp(ean13, isbn),
+ FUNCTION 1 btean13cmp(ean13, ismn),
+ FUNCTION 1 btean13cmp(ean13, issn),
+ FUNCTION 1 btean13cmp(ean13, upc);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (ean13, isbn13),
+ OPERATOR 1 = (ean13, ismn13),
+ OPERATOR 1 = (ean13, issn13),
+ OPERATOR 1 = (ean13, isbn),
+ OPERATOR 1 = (ean13, ismn),
+ OPERATOR 1 = (ean13, issn),
+ OPERATOR 1 = (ean13, upc);
+
+---------------------------------------------------
+-- ISBN13:
+CREATE FUNCTION btisbn13cmp(isbn13, isbn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn13_ops DEFAULT
+ FOR TYPE isbn13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btisbn13cmp(isbn13, isbn13);
+
+CREATE FUNCTION hashisbn13(isbn13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn13_ops DEFAULT
+ FOR TYPE isbn13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashisbn13(isbn13);
+
+-- ISBN13 vs other types:
+CREATE FUNCTION btisbn13cmp(isbn13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btisbn13cmp(isbn13, isbn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (isbn13, ean13),
+ OPERATOR 1 < (isbn13, isbn),
+ OPERATOR 2 <= (isbn13, ean13),
+ OPERATOR 2 <= (isbn13, isbn),
+ OPERATOR 3 = (isbn13, ean13),
+ OPERATOR 3 = (isbn13, isbn),
+ OPERATOR 4 >= (isbn13, ean13),
+ OPERATOR 4 >= (isbn13, isbn),
+ OPERATOR 5 > (isbn13, ean13),
+ OPERATOR 5 > (isbn13, isbn),
+ FUNCTION 1 btisbn13cmp(isbn13, ean13),
+ FUNCTION 1 btisbn13cmp(isbn13, isbn);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (isbn13, ean13),
+ OPERATOR 1 = (isbn13, isbn);
+
+---------------------------------------------------
+-- ISBN:
+CREATE FUNCTION btisbncmp(isbn, isbn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn_ops DEFAULT
+ FOR TYPE isbn USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btisbncmp(isbn, isbn);
+
+CREATE FUNCTION hashisbn(isbn)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn_ops DEFAULT
+ FOR TYPE isbn USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashisbn(isbn);
+
+-- ISBN vs other types:
+CREATE FUNCTION btisbncmp(isbn, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btisbncmp(isbn, isbn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (isbn, ean13),
+ OPERATOR 1 < (isbn, isbn13),
+ OPERATOR 2 <= (isbn, ean13),
+ OPERATOR 2 <= (isbn, isbn13),
+ OPERATOR 3 = (isbn, ean13),
+ OPERATOR 3 = (isbn, isbn13),
+ OPERATOR 4 >= (isbn, ean13),
+ OPERATOR 4 >= (isbn, isbn13),
+ OPERATOR 5 > (isbn, ean13),
+ OPERATOR 5 > (isbn, isbn13),
+ FUNCTION 1 btisbncmp(isbn, ean13),
+ FUNCTION 1 btisbncmp(isbn, isbn13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (isbn, ean13),
+ OPERATOR 1 = (isbn, isbn13);
+
+---------------------------------------------------
+-- ISMN13:
+CREATE FUNCTION btismn13cmp(ismn13, ismn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn13_ops DEFAULT
+ FOR TYPE ismn13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btismn13cmp(ismn13, ismn13);
+
+CREATE FUNCTION hashismn13(ismn13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn13_ops DEFAULT
+ FOR TYPE ismn13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashismn13(ismn13);
+
+-- ISMN13 vs other types:
+CREATE FUNCTION btismn13cmp(ismn13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btismn13cmp(ismn13, ismn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (ismn13, ean13),
+ OPERATOR 1 < (ismn13, ismn),
+ OPERATOR 2 <= (ismn13, ean13),
+ OPERATOR 2 <= (ismn13, ismn),
+ OPERATOR 3 = (ismn13, ean13),
+ OPERATOR 3 = (ismn13, ismn),
+ OPERATOR 4 >= (ismn13, ean13),
+ OPERATOR 4 >= (ismn13, ismn),
+ OPERATOR 5 > (ismn13, ean13),
+ OPERATOR 5 > (ismn13, ismn),
+ FUNCTION 1 btismn13cmp(ismn13, ean13),
+ FUNCTION 1 btismn13cmp(ismn13, ismn);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (ismn13, ean13),
+ OPERATOR 1 = (ismn13, ismn);
+
+---------------------------------------------------
+-- ISMN:
+CREATE FUNCTION btismncmp(ismn, ismn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn_ops DEFAULT
+ FOR TYPE ismn USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btismncmp(ismn, ismn);
+
+CREATE FUNCTION hashismn(ismn)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn_ops DEFAULT
+ FOR TYPE ismn USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashismn(ismn);
+
+-- ISMN vs other types:
+CREATE FUNCTION btismncmp(ismn, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btismncmp(ismn, ismn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (ismn, ean13),
+ OPERATOR 1 < (ismn, ismn13),
+ OPERATOR 2 <= (ismn, ean13),
+ OPERATOR 2 <= (ismn, ismn13),
+ OPERATOR 3 = (ismn, ean13),
+ OPERATOR 3 = (ismn, ismn13),
+ OPERATOR 4 >= (ismn, ean13),
+ OPERATOR 4 >= (ismn, ismn13),
+ OPERATOR 5 > (ismn, ean13),
+ OPERATOR 5 > (ismn, ismn13),
+ FUNCTION 1 btismncmp(ismn, ean13),
+ FUNCTION 1 btismncmp(ismn, ismn13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (ismn, ean13),
+ OPERATOR 1 = (ismn, ismn13);
+
+---------------------------------------------------
+-- ISSN13:
+CREATE FUNCTION btissn13cmp(issn13, issn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn13_ops DEFAULT
+ FOR TYPE issn13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btissn13cmp(issn13, issn13);
+
+CREATE FUNCTION hashissn13(issn13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn13_ops DEFAULT
+ FOR TYPE issn13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashissn13(issn13);
+
+-- ISSN13 vs other types:
+CREATE FUNCTION btissn13cmp(issn13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btissn13cmp(issn13, issn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (issn13, ean13),
+ OPERATOR 1 < (issn13, issn),
+ OPERATOR 2 <= (issn13, ean13),
+ OPERATOR 2 <= (issn13, issn),
+ OPERATOR 3 = (issn13, ean13),
+ OPERATOR 3 = (issn13, issn),
+ OPERATOR 4 >= (issn13, ean13),
+ OPERATOR 4 >= (issn13, issn),
+ OPERATOR 5 > (issn13, ean13),
+ OPERATOR 5 > (issn13, issn),
+ FUNCTION 1 btissn13cmp(issn13, ean13),
+ FUNCTION 1 btissn13cmp(issn13, issn);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (issn13, ean13),
+ OPERATOR 1 = (issn13, issn);
+
+---------------------------------------------------
+-- ISSN:
+CREATE FUNCTION btissncmp(issn, issn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn_ops DEFAULT
+ FOR TYPE issn USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btissncmp(issn, issn);
+
+CREATE FUNCTION hashissn(issn)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn_ops DEFAULT
+ FOR TYPE issn USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashissn(issn);
+
+-- ISSN vs other types:
+CREATE FUNCTION btissncmp(issn, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btissncmp(issn, issn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (issn, ean13),
+ OPERATOR 1 < (issn, issn13),
+ OPERATOR 2 <= (issn, ean13),
+ OPERATOR 2 <= (issn, issn13),
+ OPERATOR 3 = (issn, ean13),
+ OPERATOR 3 = (issn, issn13),
+ OPERATOR 4 >= (issn, ean13),
+ OPERATOR 4 >= (issn, issn13),
+ OPERATOR 5 > (issn, ean13),
+ OPERATOR 5 > (issn, issn13),
+ FUNCTION 1 btissncmp(issn, ean13),
+ FUNCTION 1 btissncmp(issn, issn13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (issn, ean13),
+ OPERATOR 1 = (issn, issn13);
+
+---------------------------------------------------
+-- UPC:
+CREATE FUNCTION btupccmp(upc, upc)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS upc_ops DEFAULT
+ FOR TYPE upc USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btupccmp(upc, upc);
+
+CREATE FUNCTION hashupc(upc)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS upc_ops DEFAULT
+ FOR TYPE upc USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashupc(upc);
+
+-- UPC vs other types:
+CREATE FUNCTION btupccmp(upc, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (upc, ean13),
+ OPERATOR 2 <= (upc, ean13),
+ OPERATOR 3 = (upc, ean13),
+ OPERATOR 4 >= (upc, ean13),
+ OPERATOR 5 > (upc, ean13),
+ FUNCTION 1 btupccmp(upc, ean13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (upc, ean13);
+
+--
+-- Type casts:
+--
+---------------------------------------------------
+CREATE FUNCTION isbn13(ean13)
+RETURNS isbn13
+AS 'MODULE_PATHNAME', 'isbn13_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION ismn13(ean13)
+RETURNS ismn13
+AS 'MODULE_PATHNAME', 'ismn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION issn13(ean13)
+RETURNS issn13
+AS 'MODULE_PATHNAME', 'issn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION isbn(ean13)
+RETURNS isbn
+AS 'MODULE_PATHNAME', 'isbn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION isbn(isbn13)
+RETURNS isbn
+AS 'MODULE_PATHNAME', 'isbn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION ismn(ean13)
+RETURNS ismn
+AS 'MODULE_PATHNAME', 'ismn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION issn(ean13)
+RETURNS issn
+AS 'MODULE_PATHNAME', 'issn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION upc(ean13)
+RETURNS upc
+AS 'MODULE_PATHNAME', 'upc_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+
+
+CREATE CAST (ean13 AS isbn13) WITH FUNCTION isbn13(ean13);
+CREATE CAST (ean13 AS isbn) WITH FUNCTION isbn(ean13);
+CREATE CAST (ean13 AS ismn13) WITH FUNCTION ismn13(ean13);
+CREATE CAST (ean13 AS ismn) WITH FUNCTION ismn(ean13);
+CREATE CAST (ean13 AS issn13) WITH FUNCTION issn13(ean13);
+CREATE CAST (ean13 AS issn) WITH FUNCTION issn(ean13);
+CREATE CAST (ean13 AS upc) WITH FUNCTION upc(ean13);
+
+CREATE CAST (isbn13 AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (isbn AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (ismn13 AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (ismn AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn13 AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (upc AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+
+CREATE CAST (isbn AS isbn13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (isbn13 AS isbn) WITH FUNCTION isbn(isbn13);
+CREATE CAST (ismn AS ismn13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (ismn13 AS ismn) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn AS issn13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn13 AS issn) WITHOUT FUNCTION AS ASSIGNMENT;
+
+--
+-- Validation stuff for lose types:
+--
+CREATE FUNCTION make_valid(ean13)
+ RETURNS ean13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(isbn13)
+ RETURNS isbn13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(ismn13)
+ RETURNS ismn13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(issn13)
+ RETURNS issn13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(isbn)
+ RETURNS isbn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(ismn)
+ RETURNS ismn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(issn)
+ RETURNS issn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(upc)
+ RETURNS upc
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION is_valid(ean13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(isbn13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(ismn13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(issn13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(isbn)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(ismn)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(issn)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(upc)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+
+--
+-- isn_weak(boolean) - Sets the weak input mode.
+-- This function is intended for testing use only!
+--
+CREATE FUNCTION isn_weak(boolean)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME', 'accept_weak_input'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+
+--
+-- isn_weak() - Gets the weak input mode status
+--
+CREATE FUNCTION isn_weak()
+ RETURNS boolean
+ AS 'MODULE_PATHNAME', 'weak_input_status'
+ LANGUAGE C
+ IMMUTABLE STRICT;
diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c
index 4039824..0490814 100644
--- a/contrib/isn/isn.c
+++ b/contrib/isn/isn.c
@@ -30,10 +30,14 @@ PG_MODULE_MAGIC;
enum isn_type
{
- INVALID, ANY, EAN13, ISBN, ISMN, ISSN, UPC
+ /* ISBN/ISBN13 are not interchangeable */
+ INVALID, ANY, EAN13, ISBN13, ISBN, ISMN, ISSN, UPC
};
-static const char *const isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN", "ISMN", "ISSN", "UPC"};
+static const char *const isn_names[] = {
+ "EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN13",
+ "ISBN", "ISMN", "ISSN", "UPC"
+};
static bool g_weak = false;
static bool g_initialized = false;
@@ -366,7 +370,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
/* find out the data type: */
if (strncmp("978", buf, 3) == 0)
- { /* ISBN */
+ { /* ISBN or ISBN-13 */
type = ISBN;
}
else if (strncmp("977", buf, 3) == 0)
@@ -379,7 +383,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
}
else if (strncmp("979", buf, 3) == 0)
{ /* ISBN-13 */
- type = ISBN;
+ type = ISBN13;
}
else if (*buf == '0')
{ /* UPC */
@@ -389,7 +393,8 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
{
type = EAN13;
}
- if (accept != ANY && accept != EAN13 && accept != type)
+ if (accept != ANY && accept != EAN13 && accept != type &&
+ !(accept == ISBN13 && type == ISBN))
goto eanwrongtype;
*result = ret;
@@ -571,7 +576,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
/* find out what type of hyphenation is needed: */
if (strncmp("978-", result, search) == 0)
- { /* ISBN -13 978-range */
+ { /* ISBN-13 978-range */
/* The string should be in this form: 978-??000000000-0" */
type = ISBN;
TABLE = ISBN_range;
@@ -594,7 +599,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
else if (strncmp("979-", result, search) == 0)
{ /* ISBN-13 979-range */
/* The string should be in this form: 979-??000000000-0" */
- type = ISBN;
+ type = ISBN13;
TABLE = ISBN_range_new;
TABLE_index = ISBN_index_new;
}
@@ -640,6 +645,8 @@ okay:
case UPC:
ean2UPC(result);
break;
+ case ISBN13:
+ goto eantoobig;
default:
break;
}
@@ -804,7 +811,8 @@ string2ean(const char *str, bool errorOK, ean13 *result,
/* obtain the real check digit value, validate, and convert to ean13: */
if (accept == EAN13 && type != accept)
goto eanwrongtype;
- if (accept != ANY && type != EAN13 && type != accept)
+ if (accept != ANY && type != EAN13 && type != accept &&
+ !(accept == ISBN13 && type == ISBN))
goto eanwrongtype;
switch (type)
{
@@ -816,12 +824,13 @@ string2ean(const char *str, bool errorOK, ean13 *result,
else if (strncmp("977", buf + 3, 3) == 0)
type = ISSN;
else if (strncmp("978", buf + 3, 3) == 0)
- type = ISBN;
+ type = ISBN; /* or ISBN13 */
else if (strncmp("9790", buf + 3, 4) == 0)
type = ISMN;
else if (strncmp("979", buf + 3, 3) == 0)
- type = ISBN;
- if (accept != EAN13 && accept != ANY && type != accept)
+ type = ISBN13;
+ if (accept != EAN13 && accept != ANY && type != accept &&
+ !(accept == ISBN13 && type == ISBN))
goto eanwrongtype;
break;
case ISMN:
@@ -991,6 +1000,17 @@ isbn_in(PG_FUNCTION_ARGS)
PG_RETURN_EAN13(result);
}
+PG_FUNCTION_INFO_V1(isbn13_in);
+Datum
+isbn13_in(PG_FUNCTION_ARGS)
+{
+ const char *str = PG_GETARG_CSTRING(0);
+ ean13 result;
+
+ (void) string2ean(str, false, &result, ISBN13);
+ PG_RETURN_EAN13(result);
+}
+
/* ismn_in
*/
PG_FUNCTION_INFO_V1(ismn_in);
@@ -1044,6 +1064,18 @@ isbn_cast_from_ean13(PG_FUNCTION_ARGS)
PG_RETURN_EAN13(result);
}
+PG_FUNCTION_INFO_V1(isbn13_cast_from_ean13);
+Datum
+isbn13_cast_from_ean13(PG_FUNCTION_ARGS)
+{
+ ean13 val = PG_GETARG_EAN13(0);
+ ean13 result;
+
+ (void) ean2isn(val, false, &result, ISBN13);
+
+ PG_RETURN_EAN13(result);
+}
+
PG_FUNCTION_INFO_V1(ismn_cast_from_ean13);
Datum
ismn_cast_from_ean13(PG_FUNCTION_ARGS)
diff --git a/contrib/isn/isn.control b/contrib/isn/isn.control
index cf0b2eb..f71f0bb 100644
--- a/contrib/isn/isn.control
+++ b/contrib/isn/isn.control
@@ -1,5 +1,5 @@
# isn extension
comment = 'data types for international product numbering standards'
-default_version = '1.0'
+default_version = '2.0'
module_pathname = '$libdir/isn'
relocatable = true
diff --git a/contrib/isn/sql/isn.sql b/contrib/isn/sql/isn.sql
new file mode 100644
index 0000000..0f7a557
--- /dev/null
+++ b/contrib/isn/sql/isn.sql
@@ -0,0 +1,104 @@
+--
+-- Test ISN extension
+--
+
+CREATE EXTENSION isn;
+
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+SELECT 'M123456780'::ISMN;
+SELECT '12345670'::ISSN;
+SELECT '9780123456780'::ISBN;
+SELECT '9791234567890'::ISBN13;
+SELECT '0123456789010'::UPC;
+SELECT '1234567890120'::EAN13;
+
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+SELECT '9791234567896'::ISBN; -- not an old book
+SELECT '9771234567898'::ISBN; -- not a book
+SELECT '9791234567896'::ISBN13::ISBN; -- not a an old book
+SELECT '9791234567896'::EAN13::ISBN; -- not a an old book
+SELECT '0123456789012'::ISBN; -- not a book
+
+SELECT '9790123456785'::ISBN13; -- not a book
+SELECT '9771234567898'::ISBN13; -- not a book
+SELECT '9771234567898'::EAN13::ISBN13; -- not a book
+SELECT '0123456789012'::ISBN13; -- not a book
+
+SELECT '9780123456786'::ISMN; -- not music
+SELECT '9771234567898'::ISMN; -- not music
+SELECT '9791234567896'::ISMN; -- not music
+SELECT '0123456789012'::ISMN; -- not music
+
+SELECT '9780123456786'::ISSN; -- not serial
+SELECT '9790123456785'::ISSN; -- not serial
+SELECT '9791234567896'::ISSN; -- not serial
+SELECT '0123456789012'::ISSN; -- not serial
+
+SELECT '9780123456786'::UPC; -- not a product
+SELECT '9771234567898'::UPC; -- not a product
+SELECT '9790123456785'::UPC; -- not a product
+SELECT '9791234567896'::UPC; -- not a product
+SELECT '0123456789012'::UPC; -- not a product
+
+SELECT 'postgresql...'::EAN13;
+SELECT 'postgresql...'::ISBN;
+SELECT 9780123456786::EAN13;
+SELECT 9780123456786::ISBN;
+
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-07-21 08:45 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-21 14:17 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 2 replies; 26+ messages in thread
From: Heikki Linnakangas @ 2015-07-21 08:45 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On 06/20/2015 10:04 AM, Fabien COELHO wrote:
>
>>> I think this definitely indicates a bug:
>>>
>>> regression=# select '9791020902573'::isbn;
>>> isbn
>>> ---------------
>>> 10-209-0257-4
>>> (1 row)
>>
>> Yes, indeed, this one is definitely a bug.
>
> Attached patch makes isn to distinguish when needed between ISBN and
> ISBN13. ISBN is the legacy ISBN10 number which is part of ISBN13, but not
> all ISBN13 numbers are ISBN.
>
> The initial version was confusing both types, leading to accept valid
> ISBN13 number as valid ISBN(10) number although they use the 979 prefix,
> hence the reported issues.
>
> The patch also adds some tests.
>
> There is no clear upgrade path from 1.0 to 2.0, as the ISBN "in" function
> is changed, as well as some casts. I'm not sure of a safe way to upgrade,
> because the initial version was accepting invalid ISBN which would now be
> rejected, thus some store data may be considered corrupted in a database.
> On the other hand, probably few people would use a legacy ISBN type and
> put ISBN13 number in them, hopefully? Hmmm...
10-digit ISBNs are indeed legacy, I don't have much sympathy for an
application that still uses the 10-digit isbn datatype in a table. The
cast might well be used for display purposes, though. You might do
something like "SELECT isbn_column as bisbn13, isbn_column::isbn as isbn
FROM ...". So I think your patch is OK, and we should provide an upgrade
script, and put a warning in the release notes that you should not be
using the 10-digit isbn datatype as a column type anymore.
As long as you don't use the isbn datatype in any tables or views, the
upgrade script could just DROP the datatype, and recreate it. It's
unfortunate that it won't work if you've used it in a view, but it seems
acceptable. Could you write an upgrade script like that, please?
In the long term, I think we should deprecate all the legacy "short"
datatypes, isbn, issn, ismn and upc. As a replacement for display
purposes, provide functions to print an ean13 in those legacy forms. I'm
not even sure we need the isbn13, issn13 etc. datatypes, to be honest. A
single ean13 datatype and a function to check if an EAN is an ISBN, ISSN
etc. should be enough. You could then use that in a CHECK constraint or
create a domain if you really need to. Oh, and get rid of the "weak
input mode" while we're at it - that's just horrible.
Perhaps we should add those functions now, so that you can rewrite your
application to use them now, and we could remove the legacy datatypes in
a future release.
- Heikki
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-07-21 14:17 ` Fabien COELHO <coelho@cri.ensmp.fr>
1 sibling, 0 replies; 26+ messages in thread
From: Fabien COELHO @ 2015-07-21 14:17 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
Hello Heikki,
>> There is no clear upgrade path from 1.0 to 2.0, as the ISBN "in" function
>> is changed, as well as some casts. I'm not sure of a safe way to upgrade,
>> because the initial version was accepting invalid ISBN which would now be
>> rejected, thus some store data may be considered corrupted in a database.
>> On the other hand, probably few people would use a legacy ISBN type and
>> put ISBN13 number in them, hopefully? Hmmm...
>
> 10-digit ISBNs are indeed legacy, I don't have much sympathy for an
> application that still uses the 10-digit isbn datatype in a table. The cast
> might well be used for display purposes, though. You might do something like
> "SELECT isbn_column as bisbn13, isbn_column::isbn as isbn FROM ...". So I
> think your patch is OK, and we should provide an upgrade script, and put a
> warning in the release notes that you should not be using the 10-digit isbn
> datatype as a column type anymore.
>
> As long as you don't use the isbn datatype in any tables or views, the
> upgrade script could just DROP the datatype, and recreate it. It's
> unfortunate that it won't work if you've used it in a view, but it seems
> acceptable. Could you write an upgrade script like that, please?
Probably I could. I'll have a look. It has to drop the type *and* some
casts I think. Should it cascade? Probably not, because people will no
like loosing their library data:-)
> In the long term, I think we should deprecate all the legacy "short"
> datatypes, isbn, issn, ismn and upc. As a replacement for display purposes,
> provide functions to print an ean13 in those legacy forms. I'm not even sure
> we need the isbn13, issn13 etc. datatypes, to be honest. A single ean13
> datatype and a function to check if an EAN is an ISBN, ISSN etc. should be
> enough. You could then use that in a CHECK constraint or create a domain if
> you really need to. Oh, and get rid of the "weak input mode" while we're at
> it - that's just horrible.
Hmmm. I like the principle of using a type to embed the constraint check,
and I*N13 types are fine, only the short types are indeed legacy and have
an issue.
> Perhaps we should add those functions now, so that you can rewrite your
> application to use them now, and we could remove the legacy datatypes in a
> future release.
I do not have an application, I just wrote the patch because I used these
types some time ago. Also, I'm not sure how to deprecate a type.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-07-27 09:15 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 16:03 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Jeff Janes <jeff.janes@gmail.com>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
1 sibling, 2 replies; 26+ messages in thread
From: Fabien COELHO @ 2015-07-27 09:15 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
Mon, 27 Jul 2015 11:15:17 +0200 (CEST)
Hello Heikki,
>> Attached patch makes isn to distinguish when needed between ISBN and
>> ISBN13. ISBN is the legacy ISBN10 number which is part of ISBN13, but not
>> all ISBN13 numbers are ISBN.
>>
>> The initial version was confusing both types, leading to accept valid
>> ISBN13 number as valid ISBN(10) number although they use the 979 prefix,
>> hence the reported issues.
>>
>> The patch also adds some tests.
>>
>> There is no clear upgrade path from 1.0 to 2.0, as the ISBN "in" function
>> is changed, as well as some casts. I'm not sure of a safe way to upgrade,
>> because the initial version was accepting invalid ISBN which would now be
>> rejected, thus some store data may be considered corrupted in a database.
>> On the other hand, probably few people would use a legacy ISBN type and
>> put ISBN13 number in them, hopefully? Hmmm...
>
> 10-digit ISBNs are indeed legacy, I don't have much sympathy for an
> application that still uses the 10-digit isbn datatype in a table. The cast
> might well be used for display purposes, though. You might do something like
> "SELECT isbn_column as bisbn13, isbn_column::isbn as isbn FROM ...". So I
> think your patch is OK, and we should provide an upgrade script,
After some tests, it seems that an upgrade script cannot be provided,
or I missed something.
Basically version 1.0 was confusing ISBN & ISBN13, and for upgrading the
ISBN type definition must be modified. However, there is no such thing as
ALTER TYPE, and trying DROP TYPE/ALTER TYPE is rejected because the type
belongs to an extension (hey I know that, this is what is being done!).
Probably this is some kind of feature/bug of the extension mecanism, that
I'm not planing to fix for isn...
So the v2 attached provides the two versions (1.0 more or less bug
compatible, 2.0 without the confusion bug), without path for an upgrade
between the two, can't help it. Maybe providing a 1.0 buggy version is a
bad idea, though.
> and put a warning in the release notes that you should not be using the
> 10-digit isbn datatype as a column type anymore.
A warning would be a good think.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
isn-fix-2.patch (text/x-diff, 89.7K) download
diff --git a/contrib/isn/Makefile b/contrib/isn/Makefile
index 75c07a8..a95e560 100644
--- a/contrib/isn/Makefile
+++ b/contrib/isn/Makefile
@@ -3,9 +3,11 @@
MODULES = isn
EXTENSION = isn
-DATA = isn--1.0.sql isn--unpackaged--1.0.sql
+DATA = isn--1.0.sql isn--2.0.sql isn--unpackaged--1.0.sql
PGFILEDESC = "isn - data types for international product numbering standards"
+REGRESS = isn
+
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/isn/expected/isn.out b/contrib/isn/expected/isn.out
new file mode 100644
index 0000000..954f62b
--- /dev/null
+++ b/contrib/isn/expected/isn.out
@@ -0,0 +1,229 @@
+--
+-- Test ISN extension
+--
+CREATE EXTENSION isn;
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+ ean13 | ean13 | ean13 | ean13 | ean13 | ean13
+-------------------+-------------------+-----------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 979-0-1234-5678-5 | 979-123456789-6 | 977-1234-567-89-8 | 012-345678901-2 | 123-456789012-8
+(1 row)
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+ isbn | isbn | isbn | isbn
+---------------+---------------+---------------+---------------
+ 0-12-345678-9 | 1-234-56789-X | 0-12-345678-9 | 0-12-345678-9
+(1 row)
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+ isbn13 | isbn13 | isbn13 | isbn13
+-------------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 978-1-234-56789-7 | 979-123456789-6 | 979-123456789-6
+(1 row)
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+ ismn | ismn | ismn | ismn
+---------------+---------------+---------------+---------------
+ M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5
+(1 row)
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+ ismn13 | ismn13 | ismn13
+-------------------+-------------------+-------------------
+ 979-0-1234-5678-5 | 979-0-1234-5678-5 | 979-0-1234-5678-5
+(1 row)
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+ issn | issn
+-----------+-----------
+ 1234-5679 | 1234-5679
+(1 row)
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+ issn13 | issn13 | issn13 | issn13
+-------------------+-------------------+-------------------+-------------------
+ 977-1234-567-00-3 | 977-1234-567-00-3 | 977-1234-567-89-8 | 977-1234-567-89-8
+(1 row)
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+ upc | upc
+--------------+--------------
+ 123456789012 | 123456789012
+(1 row)
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+ERROR: invalid check digit for ISBN number: "1234567890", should be X
+LINE 1: SELECT '1234567890'::ISBN;
+ ^
+SELECT 'M123456780'::ISMN;
+ERROR: invalid check digit for ISMN number: "M123456780", should be 5
+LINE 1: SELECT 'M123456780'::ISMN;
+ ^
+SELECT '12345670'::ISSN;
+ERROR: invalid check digit for ISSN number: "12345670", should be 9
+LINE 1: SELECT '12345670'::ISSN;
+ ^
+SELECT '9780123456780'::ISBN;
+ERROR: invalid check digit for ISBN number: "9780123456780", should be 6
+LINE 1: SELECT '9780123456780'::ISBN;
+ ^
+SELECT '9791234567890'::ISBN13;
+ERROR: invalid check digit for ISBN13 number: "9791234567890", should be 6
+LINE 1: SELECT '9791234567890'::ISBN13;
+ ^
+SELECT '0123456789010'::UPC;
+ERROR: invalid check digit for UPC number: "0123456789010", should be 2
+LINE 1: SELECT '0123456789010'::UPC;
+ ^
+SELECT '1234567890120'::EAN13;
+ERROR: invalid check digit for EAN13 number: "1234567890120", should be 8
+LINE 1: SELECT '1234567890120'::EAN13;
+ ^
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+ERROR: cannot cast ISMN to ISBN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN;
+ ^
+SELECT '9791234567896'::ISBN; -- not an old book
+ERROR: cannot cast ISBN13 to ISBN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISBN;
+ ^
+SELECT '9771234567898'::ISBN; -- not a book
+ERROR: cannot cast ISSN to ISBN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN;
+ ^
+SELECT '9791234567896'::ISBN13::ISBN; -- not a an old book
+ERROR: cannot cast EAN13(ISBN13) to ISBN for number: "9791234567896"
+SELECT '9791234567896'::EAN13::ISBN; -- not a an old book
+ERROR: cannot cast EAN13(ISBN13) to ISBN for number: "9791234567896"
+SELECT '0123456789012'::ISBN; -- not a book
+ERROR: cannot cast UPC to ISBN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN;
+ ^
+SELECT '9790123456785'::ISBN13; -- not a book
+ERROR: cannot cast ISMN to ISBN13 for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN13;
+ ^
+SELECT '9771234567898'::ISBN13; -- not a book
+ERROR: cannot cast ISSN to ISBN13 for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN13;
+ ^
+SELECT '9771234567898'::EAN13::ISBN13; -- not a book
+ERROR: cannot cast EAN13(ISSN) to ISBN13 for number: "9771234567898"
+SELECT '0123456789012'::ISBN13; -- not a book
+ERROR: cannot cast UPC to ISBN13 for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN13;
+ ^
+SELECT '9780123456786'::ISMN; -- not music
+ERROR: cannot cast ISBN to ISMN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISMN;
+ ^
+SELECT '9771234567898'::ISMN; -- not music
+ERROR: cannot cast ISSN to ISMN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISMN;
+ ^
+SELECT '9791234567896'::ISMN; -- not music
+ERROR: cannot cast ISBN13 to ISMN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISMN;
+ ^
+SELECT '0123456789012'::ISMN; -- not music
+ERROR: cannot cast UPC to ISMN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISMN;
+ ^
+SELECT '9780123456786'::ISSN; -- not serial
+ERROR: cannot cast ISBN to ISSN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISSN;
+ ^
+SELECT '9790123456785'::ISSN; -- not serial
+ERROR: cannot cast ISMN to ISSN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISSN;
+ ^
+SELECT '9791234567896'::ISSN; -- not serial
+ERROR: cannot cast ISBN13 to ISSN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISSN;
+ ^
+SELECT '0123456789012'::ISSN; -- not serial
+ERROR: cannot cast UPC to ISSN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISSN;
+ ^
+SELECT '9780123456786'::UPC; -- not a product
+ERROR: cannot cast ISBN to UPC for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::UPC;
+ ^
+SELECT '9771234567898'::UPC; -- not a product
+ERROR: cannot cast ISSN to UPC for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::UPC;
+ ^
+SELECT '9790123456785'::UPC; -- not a product
+ERROR: cannot cast ISMN to UPC for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::UPC;
+ ^
+SELECT '9791234567896'::UPC; -- not a product
+ERROR: cannot cast ISBN13 to UPC for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::UPC;
+ ^
+SELECT '0123456789012'::UPC; -- not a product
+ upc
+--------------
+ 123456789012
+(1 row)
+
+SELECT 'postgresql...'::EAN13;
+ERROR: invalid input syntax for EAN13 number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::EAN13;
+ ^
+SELECT 'postgresql...'::ISBN;
+ERROR: invalid input syntax for ISBN number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::ISBN;
+ ^
+SELECT 9780123456786::EAN13;
+ERROR: cannot cast type bigint to ean13
+LINE 1: SELECT 9780123456786::EAN13;
+ ^
+SELECT 9780123456786::ISBN;
+ERROR: cannot cast type bigint to isbn
+LINE 1: SELECT 9780123456786::ISBN;
+ ^
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+ ok | ok | nope
+----+----+------
+ t | t | t
+(1 row)
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
diff --git a/contrib/isn/isn--2.0.sql b/contrib/isn/isn--2.0.sql
new file mode 100644
index 0000000..1a3b64a
--- /dev/null
+++ b/contrib/isn/isn--2.0.sql
@@ -0,0 +1,3200 @@
+/* contrib/isn/isn--1.0.sql */
+
+-- complain if script is sourced in psql, rather than via CREATE EXTENSION
+\echo Use "CREATE EXTENSION isn" to load this file. \quit
+
+-- Example:
+-- create table test ( id isbn );
+-- insert into test values('978-0-393-04002-9');
+--
+-- select isbn('978-0-393-04002-9');
+-- select isbn13('0-901690-54-6');
+--
+
+--
+-- Input and output functions and data types:
+--
+---------------------------------------------------
+CREATE FUNCTION ean13_in(cstring)
+ RETURNS ean13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(ean13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE ean13 (
+ INPUT = ean13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE ean13
+ IS 'International European Article Number (EAN13)';
+
+CREATE FUNCTION isbn13_in(cstring)
+ RETURNS isbn13
+ AS 'MODULE_PATHNAME', 'isbn13_in'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(isbn13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE isbn13 (
+ INPUT = isbn13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE isbn13
+ IS 'International Standard Book Number 13 (ISBN13)';
+
+CREATE FUNCTION ismn13_in(cstring)
+ RETURNS ismn13
+ AS 'MODULE_PATHNAME', 'ismn_in'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(ismn13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE ismn13 (
+ INPUT = ismn13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE ismn13
+ IS 'International Standard Music Number 13 (ISMN13)';
+
+CREATE FUNCTION issn13_in(cstring)
+ RETURNS issn13
+ AS 'MODULE_PATHNAME', 'issn_in'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION ean13_out(issn13)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE issn13 (
+ INPUT = issn13_in,
+ OUTPUT = ean13_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE issn13
+ IS 'International Standard Serial Number 13 (ISSN13)';
+
+-- Short format:
+
+CREATE FUNCTION isbn10_in(cstring)
+ RETURNS isbn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(isbn)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE isbn (
+ INPUT = isbn10_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE isbn
+ IS '(Obsolete) International Standard Book Number (ISBN)';
+
+CREATE FUNCTION ismn_in(cstring)
+ RETURNS ismn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(ismn)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE ismn (
+ INPUT = ismn_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE ismn
+ IS 'International Standard Music Number (ISMN)';
+
+CREATE FUNCTION issn_in(cstring)
+ RETURNS issn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(issn)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE issn (
+ INPUT = issn_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE issn
+ IS 'International Standard Serial Number (ISSN)';
+
+CREATE FUNCTION upc_in(cstring)
+ RETURNS upc
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION isn_out(upc)
+ RETURNS cstring
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE TYPE upc (
+ INPUT = upc_in,
+ OUTPUT = isn_out,
+ LIKE = pg_catalog.int8
+);
+COMMENT ON TYPE upc
+ IS 'Universal Product Code (UPC)';
+
+--
+-- Operator functions:
+--
+---------------------------------------------------
+-- EAN13:
+CREATE FUNCTION isnlt(ean13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, isbn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, ismn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, issn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, issn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, issn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, issn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, issn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, issn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, isbn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, isbn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, isbn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, isbn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, isbn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, isbn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, ismn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, ismn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, ismn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, ismn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, ismn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, ismn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, issn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, issn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, issn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, issn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, issn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, issn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ean13, upc)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ean13, upc)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ean13, upc)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ean13, upc)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ean13, upc)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ean13, upc)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISBN13:
+CREATE FUNCTION isnlt(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn13, isbn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn13, isbn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISBN:
+CREATE FUNCTION isnlt(isbn, isbn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn, isbn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn, isbn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn, isbn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn, isbn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn, isbn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn, isbn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(isbn, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(isbn, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(isbn, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(isbn, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(isbn, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(isbn, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISMN13:
+CREATE FUNCTION isnlt(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn13, ismn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn13, ismn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISMN:
+CREATE FUNCTION isnlt(ismn, ismn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn, ismn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn, ismn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn, ismn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn, ismn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn, ismn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn, ismn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(ismn, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(ismn, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(ismn, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(ismn, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(ismn, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(ismn, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISSN13:
+CREATE FUNCTION isnlt(issn13, issn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn13, issn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn13, issn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn13, issn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn13, issn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn13, issn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn13, issn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn13, issn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn13, issn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn13, issn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn13, issn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn13, issn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn13, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn13, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn13, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn13, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn13, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn13, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- ISSN:
+CREATE FUNCTION isnlt(issn, issn)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn, issn)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn, issn)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn, issn)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn, issn)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn, issn)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn, issn13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn, issn13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn, issn13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn, issn13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn, issn13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn, issn13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(issn, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(issn, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(issn, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(issn, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(issn, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(issn, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+---------------------------------------------------
+-- UPC:
+CREATE FUNCTION isnlt(upc, upc)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(upc, upc)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(upc, upc)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(upc, upc)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(upc, upc)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(upc, upc)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION isnlt(upc, ean13)
+ RETURNS boolean
+ AS 'int8lt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnle(upc, ean13)
+ RETURNS boolean
+ AS 'int8le'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isneq(upc, ean13)
+ RETURNS boolean
+ AS 'int8eq'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnge(upc, ean13)
+ RETURNS boolean
+ AS 'int8ge'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isngt(upc, ean13)
+ RETURNS boolean
+ AS 'int8gt'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION isnne(upc, ean13)
+ RETURNS boolean
+ AS 'int8ne'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+--
+-- Now the operators:
+--
+
+--
+-- EAN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = issn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel);
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ean13,
+ RIGHTARG = upc,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISBN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn13,
+ RIGHTARG = isbn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISBN operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn,
+ RIGHTARG = isbn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn,
+ RIGHTARG = isbn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = isbn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISMN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn13,
+ RIGHTARG = ismn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISMN operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn,
+ RIGHTARG = ismn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn,
+ RIGHTARG = ismn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = ismn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISSN13 operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn13,
+ RIGHTARG = issn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn13,
+ RIGHTARG = issn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn13,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- ISSN operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn,
+ RIGHTARG = issn,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn,
+ RIGHTARG = issn13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = issn,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- UPC operators:
+--
+---------------------------------------------------
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = upc,
+ RIGHTARG = upc,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+CREATE OPERATOR < (
+ PROCEDURE = isnlt,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = >,
+ NEGATOR = >=,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR <= (
+ PROCEDURE = isnle,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = >=,
+ NEGATOR = >,
+ RESTRICT = scalarltsel,
+ JOIN = scalarltjoinsel);
+CREATE OPERATOR = (
+ PROCEDURE = isneq,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = =,
+ NEGATOR = <>,
+ RESTRICT = eqsel,
+ JOIN = eqjoinsel,
+ MERGES,
+ HASHES);
+CREATE OPERATOR >= (
+ PROCEDURE = isnge,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = <=,
+ NEGATOR = <,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR > (
+ PROCEDURE = isngt,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = <,
+ NEGATOR = <=,
+ RESTRICT = scalargtsel,
+ JOIN = scalargtjoinsel );
+CREATE OPERATOR <> (
+ PROCEDURE = isnne,
+ LEFTARG = upc,
+ RIGHTARG = ean13,
+ COMMUTATOR = <>,
+ NEGATOR = =,
+ RESTRICT = neqsel,
+ JOIN = neqjoinsel);
+
+--
+-- Operator families for the various operator classes:
+--
+---------------------------------------------------
+
+CREATE OPERATOR FAMILY isn_ops USING btree;
+CREATE OPERATOR FAMILY isn_ops USING hash;
+
+--
+-- Operator classes:
+--
+---------------------------------------------------
+-- EAN13:
+CREATE FUNCTION btean13cmp(ean13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ean13_ops DEFAULT
+ FOR TYPE ean13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btean13cmp(ean13, ean13);
+
+CREATE FUNCTION hashean13(ean13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal' IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ean13_ops DEFAULT
+ FOR TYPE ean13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashean13(ean13);
+
+-- EAN13 vs other types:
+CREATE FUNCTION btean13cmp(ean13, isbn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, ismn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, issn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, isbn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, ismn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, issn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btean13cmp(ean13, upc)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (ean13, isbn13),
+ OPERATOR 1 < (ean13, ismn13),
+ OPERATOR 1 < (ean13, issn13),
+ OPERATOR 1 < (ean13, isbn),
+ OPERATOR 1 < (ean13, ismn),
+ OPERATOR 1 < (ean13, issn),
+ OPERATOR 1 < (ean13, upc),
+ OPERATOR 2 <= (ean13, isbn13),
+ OPERATOR 2 <= (ean13, ismn13),
+ OPERATOR 2 <= (ean13, issn13),
+ OPERATOR 2 <= (ean13, isbn),
+ OPERATOR 2 <= (ean13, ismn),
+ OPERATOR 2 <= (ean13, issn),
+ OPERATOR 2 <= (ean13, upc),
+ OPERATOR 3 = (ean13, isbn13),
+ OPERATOR 3 = (ean13, ismn13),
+ OPERATOR 3 = (ean13, issn13),
+ OPERATOR 3 = (ean13, isbn),
+ OPERATOR 3 = (ean13, ismn),
+ OPERATOR 3 = (ean13, issn),
+ OPERATOR 3 = (ean13, upc),
+ OPERATOR 4 >= (ean13, isbn13),
+ OPERATOR 4 >= (ean13, ismn13),
+ OPERATOR 4 >= (ean13, issn13),
+ OPERATOR 4 >= (ean13, isbn),
+ OPERATOR 4 >= (ean13, ismn),
+ OPERATOR 4 >= (ean13, issn),
+ OPERATOR 4 >= (ean13, upc),
+ OPERATOR 5 > (ean13, isbn13),
+ OPERATOR 5 > (ean13, ismn13),
+ OPERATOR 5 > (ean13, issn13),
+ OPERATOR 5 > (ean13, isbn),
+ OPERATOR 5 > (ean13, ismn),
+ OPERATOR 5 > (ean13, issn),
+ OPERATOR 5 > (ean13, upc),
+ FUNCTION 1 btean13cmp(ean13, isbn13),
+ FUNCTION 1 btean13cmp(ean13, ismn13),
+ FUNCTION 1 btean13cmp(ean13, issn13),
+ FUNCTION 1 btean13cmp(ean13, isbn),
+ FUNCTION 1 btean13cmp(ean13, ismn),
+ FUNCTION 1 btean13cmp(ean13, issn),
+ FUNCTION 1 btean13cmp(ean13, upc);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (ean13, isbn13),
+ OPERATOR 1 = (ean13, ismn13),
+ OPERATOR 1 = (ean13, issn13),
+ OPERATOR 1 = (ean13, isbn),
+ OPERATOR 1 = (ean13, ismn),
+ OPERATOR 1 = (ean13, issn),
+ OPERATOR 1 = (ean13, upc);
+
+---------------------------------------------------
+-- ISBN13:
+CREATE FUNCTION btisbn13cmp(isbn13, isbn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn13_ops DEFAULT
+ FOR TYPE isbn13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btisbn13cmp(isbn13, isbn13);
+
+CREATE FUNCTION hashisbn13(isbn13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn13_ops DEFAULT
+ FOR TYPE isbn13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashisbn13(isbn13);
+
+-- ISBN13 vs other types:
+CREATE FUNCTION btisbn13cmp(isbn13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btisbn13cmp(isbn13, isbn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (isbn13, ean13),
+ OPERATOR 1 < (isbn13, isbn),
+ OPERATOR 2 <= (isbn13, ean13),
+ OPERATOR 2 <= (isbn13, isbn),
+ OPERATOR 3 = (isbn13, ean13),
+ OPERATOR 3 = (isbn13, isbn),
+ OPERATOR 4 >= (isbn13, ean13),
+ OPERATOR 4 >= (isbn13, isbn),
+ OPERATOR 5 > (isbn13, ean13),
+ OPERATOR 5 > (isbn13, isbn),
+ FUNCTION 1 btisbn13cmp(isbn13, ean13),
+ FUNCTION 1 btisbn13cmp(isbn13, isbn);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (isbn13, ean13),
+ OPERATOR 1 = (isbn13, isbn);
+
+---------------------------------------------------
+-- ISBN:
+CREATE FUNCTION btisbncmp(isbn, isbn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn_ops DEFAULT
+ FOR TYPE isbn USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btisbncmp(isbn, isbn);
+
+CREATE FUNCTION hashisbn(isbn)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS isbn_ops DEFAULT
+ FOR TYPE isbn USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashisbn(isbn);
+
+-- ISBN vs other types:
+CREATE FUNCTION btisbncmp(isbn, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btisbncmp(isbn, isbn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (isbn, ean13),
+ OPERATOR 1 < (isbn, isbn13),
+ OPERATOR 2 <= (isbn, ean13),
+ OPERATOR 2 <= (isbn, isbn13),
+ OPERATOR 3 = (isbn, ean13),
+ OPERATOR 3 = (isbn, isbn13),
+ OPERATOR 4 >= (isbn, ean13),
+ OPERATOR 4 >= (isbn, isbn13),
+ OPERATOR 5 > (isbn, ean13),
+ OPERATOR 5 > (isbn, isbn13),
+ FUNCTION 1 btisbncmp(isbn, ean13),
+ FUNCTION 1 btisbncmp(isbn, isbn13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (isbn, ean13),
+ OPERATOR 1 = (isbn, isbn13);
+
+---------------------------------------------------
+-- ISMN13:
+CREATE FUNCTION btismn13cmp(ismn13, ismn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn13_ops DEFAULT
+ FOR TYPE ismn13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btismn13cmp(ismn13, ismn13);
+
+CREATE FUNCTION hashismn13(ismn13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn13_ops DEFAULT
+ FOR TYPE ismn13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashismn13(ismn13);
+
+-- ISMN13 vs other types:
+CREATE FUNCTION btismn13cmp(ismn13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btismn13cmp(ismn13, ismn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (ismn13, ean13),
+ OPERATOR 1 < (ismn13, ismn),
+ OPERATOR 2 <= (ismn13, ean13),
+ OPERATOR 2 <= (ismn13, ismn),
+ OPERATOR 3 = (ismn13, ean13),
+ OPERATOR 3 = (ismn13, ismn),
+ OPERATOR 4 >= (ismn13, ean13),
+ OPERATOR 4 >= (ismn13, ismn),
+ OPERATOR 5 > (ismn13, ean13),
+ OPERATOR 5 > (ismn13, ismn),
+ FUNCTION 1 btismn13cmp(ismn13, ean13),
+ FUNCTION 1 btismn13cmp(ismn13, ismn);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (ismn13, ean13),
+ OPERATOR 1 = (ismn13, ismn);
+
+---------------------------------------------------
+-- ISMN:
+CREATE FUNCTION btismncmp(ismn, ismn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn_ops DEFAULT
+ FOR TYPE ismn USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btismncmp(ismn, ismn);
+
+CREATE FUNCTION hashismn(ismn)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS ismn_ops DEFAULT
+ FOR TYPE ismn USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashismn(ismn);
+
+-- ISMN vs other types:
+CREATE FUNCTION btismncmp(ismn, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btismncmp(ismn, ismn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (ismn, ean13),
+ OPERATOR 1 < (ismn, ismn13),
+ OPERATOR 2 <= (ismn, ean13),
+ OPERATOR 2 <= (ismn, ismn13),
+ OPERATOR 3 = (ismn, ean13),
+ OPERATOR 3 = (ismn, ismn13),
+ OPERATOR 4 >= (ismn, ean13),
+ OPERATOR 4 >= (ismn, ismn13),
+ OPERATOR 5 > (ismn, ean13),
+ OPERATOR 5 > (ismn, ismn13),
+ FUNCTION 1 btismncmp(ismn, ean13),
+ FUNCTION 1 btismncmp(ismn, ismn13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (ismn, ean13),
+ OPERATOR 1 = (ismn, ismn13);
+
+---------------------------------------------------
+-- ISSN13:
+CREATE FUNCTION btissn13cmp(issn13, issn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn13_ops DEFAULT
+ FOR TYPE issn13 USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btissn13cmp(issn13, issn13);
+
+CREATE FUNCTION hashissn13(issn13)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn13_ops DEFAULT
+ FOR TYPE issn13 USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashissn13(issn13);
+
+-- ISSN13 vs other types:
+CREATE FUNCTION btissn13cmp(issn13, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btissn13cmp(issn13, issn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (issn13, ean13),
+ OPERATOR 1 < (issn13, issn),
+ OPERATOR 2 <= (issn13, ean13),
+ OPERATOR 2 <= (issn13, issn),
+ OPERATOR 3 = (issn13, ean13),
+ OPERATOR 3 = (issn13, issn),
+ OPERATOR 4 >= (issn13, ean13),
+ OPERATOR 4 >= (issn13, issn),
+ OPERATOR 5 > (issn13, ean13),
+ OPERATOR 5 > (issn13, issn),
+ FUNCTION 1 btissn13cmp(issn13, ean13),
+ FUNCTION 1 btissn13cmp(issn13, issn);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (issn13, ean13),
+ OPERATOR 1 = (issn13, issn);
+
+---------------------------------------------------
+-- ISSN:
+CREATE FUNCTION btissncmp(issn, issn)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn_ops DEFAULT
+ FOR TYPE issn USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btissncmp(issn, issn);
+
+CREATE FUNCTION hashissn(issn)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS issn_ops DEFAULT
+ FOR TYPE issn USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashissn(issn);
+
+-- ISSN vs other types:
+CREATE FUNCTION btissncmp(issn, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+CREATE FUNCTION btissncmp(issn, issn13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (issn, ean13),
+ OPERATOR 1 < (issn, issn13),
+ OPERATOR 2 <= (issn, ean13),
+ OPERATOR 2 <= (issn, issn13),
+ OPERATOR 3 = (issn, ean13),
+ OPERATOR 3 = (issn, issn13),
+ OPERATOR 4 >= (issn, ean13),
+ OPERATOR 4 >= (issn, issn13),
+ OPERATOR 5 > (issn, ean13),
+ OPERATOR 5 > (issn, issn13),
+ FUNCTION 1 btissncmp(issn, ean13),
+ FUNCTION 1 btissncmp(issn, issn13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (issn, ean13),
+ OPERATOR 1 = (issn, issn13);
+
+---------------------------------------------------
+-- UPC:
+CREATE FUNCTION btupccmp(upc, upc)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS upc_ops DEFAULT
+ FOR TYPE upc USING btree FAMILY isn_ops AS
+ OPERATOR 1 <,
+ OPERATOR 2 <=,
+ OPERATOR 3 =,
+ OPERATOR 4 >=,
+ OPERATOR 5 >,
+ FUNCTION 1 btupccmp(upc, upc);
+
+CREATE FUNCTION hashupc(upc)
+ RETURNS int4
+ AS 'hashint8'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+CREATE OPERATOR CLASS upc_ops DEFAULT
+ FOR TYPE upc USING hash FAMILY isn_ops AS
+ OPERATOR 1 =,
+ FUNCTION 1 hashupc(upc);
+
+-- UPC vs other types:
+CREATE FUNCTION btupccmp(upc, ean13)
+ RETURNS int4
+ AS 'btint8cmp'
+ LANGUAGE 'internal'
+ IMMUTABLE STRICT;
+
+ALTER OPERATOR FAMILY isn_ops USING btree ADD
+ OPERATOR 1 < (upc, ean13),
+ OPERATOR 2 <= (upc, ean13),
+ OPERATOR 3 = (upc, ean13),
+ OPERATOR 4 >= (upc, ean13),
+ OPERATOR 5 > (upc, ean13),
+ FUNCTION 1 btupccmp(upc, ean13);
+
+ALTER OPERATOR FAMILY isn_ops USING hash ADD
+ OPERATOR 1 = (upc, ean13);
+
+--
+-- Type casts:
+--
+---------------------------------------------------
+CREATE FUNCTION isbn13(ean13)
+RETURNS isbn13
+AS 'MODULE_PATHNAME', 'isbn13_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION ismn13(ean13)
+RETURNS ismn13
+AS 'MODULE_PATHNAME', 'ismn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION issn13(ean13)
+RETURNS issn13
+AS 'MODULE_PATHNAME', 'issn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION isbn(ean13)
+RETURNS isbn
+AS 'MODULE_PATHNAME', 'isbn10_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION isbn(isbn13)
+RETURNS isbn
+AS 'MODULE_PATHNAME', 'isbn10_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION ismn(ean13)
+RETURNS ismn
+AS 'MODULE_PATHNAME', 'ismn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION issn(ean13)
+RETURNS issn
+AS 'MODULE_PATHNAME', 'issn_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+CREATE FUNCTION upc(ean13)
+RETURNS upc
+AS 'MODULE_PATHNAME', 'upc_cast_from_ean13'
+LANGUAGE C IMMUTABLE STRICT;
+
+
+CREATE CAST (ean13 AS isbn13) WITH FUNCTION isbn13(ean13);
+CREATE CAST (ean13 AS isbn) WITH FUNCTION isbn(ean13);
+CREATE CAST (ean13 AS ismn13) WITH FUNCTION ismn13(ean13);
+CREATE CAST (ean13 AS ismn) WITH FUNCTION ismn(ean13);
+CREATE CAST (ean13 AS issn13) WITH FUNCTION issn13(ean13);
+CREATE CAST (ean13 AS issn) WITH FUNCTION issn(ean13);
+CREATE CAST (ean13 AS upc) WITH FUNCTION upc(ean13);
+
+CREATE CAST (isbn13 AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (isbn AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (ismn13 AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (ismn AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn13 AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (upc AS ean13) WITHOUT FUNCTION AS ASSIGNMENT;
+
+CREATE CAST (isbn AS isbn13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (isbn13 AS isbn) WITH FUNCTION isbn(isbn13);
+CREATE CAST (ismn AS ismn13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (ismn13 AS ismn) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn AS issn13) WITHOUT FUNCTION AS ASSIGNMENT;
+CREATE CAST (issn13 AS issn) WITHOUT FUNCTION AS ASSIGNMENT;
+
+--
+-- Validation stuff for lose types:
+--
+CREATE FUNCTION make_valid(ean13)
+ RETURNS ean13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(isbn13)
+ RETURNS isbn13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(ismn13)
+ RETURNS ismn13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(issn13)
+ RETURNS issn13
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(isbn)
+ RETURNS isbn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(ismn)
+ RETURNS ismn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(issn)
+ RETURNS issn
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION make_valid(upc)
+ RETURNS upc
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+
+CREATE FUNCTION is_valid(ean13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(isbn13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(ismn13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(issn13)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(isbn)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(ismn)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(issn)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+CREATE FUNCTION is_valid(upc)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+
+--
+-- isn_weak(boolean) - Sets the weak input mode.
+-- This function is intended for testing use only!
+--
+CREATE FUNCTION isn_weak(boolean)
+ RETURNS boolean
+ AS 'MODULE_PATHNAME', 'accept_weak_input'
+ LANGUAGE C
+ IMMUTABLE STRICT;
+
+--
+-- isn_weak() - Gets the weak input mode status
+--
+CREATE FUNCTION isn_weak()
+ RETURNS boolean
+ AS 'MODULE_PATHNAME', 'weak_input_status'
+ LANGUAGE C
+ IMMUTABLE STRICT;
diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c
index 4039824..1e98c3e 100644
--- a/contrib/isn/isn.c
+++ b/contrib/isn/isn.c
@@ -30,10 +30,14 @@ PG_MODULE_MAGIC;
enum isn_type
{
- INVALID, ANY, EAN13, ISBN, ISMN, ISSN, UPC
+ /* ISBN/ISBN13 are not interchangeable */
+ INVALID, ANY, EAN13, ISBN13, ISBN, ISMN, ISSN, UPC
};
-static const char *const isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN", "ISMN", "ISSN", "UPC"};
+static const char *const isn_names[] = {
+ "EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN13",
+ "ISBN", "ISMN", "ISSN", "UPC"
+};
static bool g_weak = false;
static bool g_initialized = false;
@@ -366,7 +370,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
/* find out the data type: */
if (strncmp("978", buf, 3) == 0)
- { /* ISBN */
+ { /* ISBN or ISBN-13 */
type = ISBN;
}
else if (strncmp("977", buf, 3) == 0)
@@ -379,7 +383,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
}
else if (strncmp("979", buf, 3) == 0)
{ /* ISBN-13 */
- type = ISBN;
+ type = ISBN13;
}
else if (*buf == '0')
{ /* UPC */
@@ -389,7 +393,8 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
{
type = EAN13;
}
- if (accept != ANY && accept != EAN13 && accept != type)
+ if (accept != ANY && accept != EAN13 && accept != type &&
+ !(accept == ISBN13 && type == ISBN))
goto eanwrongtype;
*result = ret;
@@ -571,7 +576,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
/* find out what type of hyphenation is needed: */
if (strncmp("978-", result, search) == 0)
- { /* ISBN -13 978-range */
+ { /* ISBN-13 978-range */
/* The string should be in this form: 978-??000000000-0" */
type = ISBN;
TABLE = ISBN_range;
@@ -594,7 +599,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
else if (strncmp("979-", result, search) == 0)
{ /* ISBN-13 979-range */
/* The string should be in this form: 979-??000000000-0" */
- type = ISBN;
+ type = ISBN13;
TABLE = ISBN_range_new;
TABLE_index = ISBN_index_new;
}
@@ -640,6 +645,8 @@ okay:
case UPC:
ean2UPC(result);
break;
+ case ISBN13:
+ goto eantoobig;
default:
break;
}
@@ -804,7 +811,8 @@ string2ean(const char *str, bool errorOK, ean13 *result,
/* obtain the real check digit value, validate, and convert to ean13: */
if (accept == EAN13 && type != accept)
goto eanwrongtype;
- if (accept != ANY && type != EAN13 && type != accept)
+ if (accept != ANY && type != EAN13 && type != accept &&
+ !(accept == ISBN13 && type == ISBN))
goto eanwrongtype;
switch (type)
{
@@ -816,12 +824,13 @@ string2ean(const char *str, bool errorOK, ean13 *result,
else if (strncmp("977", buf + 3, 3) == 0)
type = ISSN;
else if (strncmp("978", buf + 3, 3) == 0)
- type = ISBN;
+ type = ISBN; /* or ISBN13 */
else if (strncmp("9790", buf + 3, 4) == 0)
type = ISMN;
else if (strncmp("979", buf + 3, 3) == 0)
- type = ISBN;
- if (accept != EAN13 && accept != ANY && type != accept)
+ type = ISBN13;
+ if (accept != EAN13 && accept != ANY && type != accept &&
+ !(accept == ISBN13 && type == ISBN))
goto eanwrongtype;
break;
case ISMN:
@@ -978,11 +987,9 @@ ean13_in(PG_FUNCTION_ARGS)
PG_RETURN_EAN13(result);
}
-/* isbn_in
- */
-PG_FUNCTION_INFO_V1(isbn_in);
+PG_FUNCTION_INFO_V1(isbn10_in);
Datum
-isbn_in(PG_FUNCTION_ARGS)
+isbn10_in(PG_FUNCTION_ARGS)
{
const char *str = PG_GETARG_CSTRING(0);
ean13 result;
@@ -991,6 +998,32 @@ isbn_in(PG_FUNCTION_ARGS)
PG_RETURN_EAN13(result);
}
+PG_FUNCTION_INFO_V1(isbn13_in);
+Datum
+isbn13_in(PG_FUNCTION_ARGS)
+{
+ const char *str = PG_GETARG_CSTRING(0);
+ ean13 result;
+
+ (void) string2ean(str, false, &result, ISBN13);
+ PG_RETURN_EAN13(result);
+}
+
+/* for backward compatibility... */
+#ifndef PG_FUNCTION_ARGS_VAR
+#define PG_FUNCTION_ARGS_VAR fcinfo
+#endif /* PG_FUNCTION_ARGS_VAR */
+
+/* This function is provided for being bug-compatible with isn 1.0,
+ * where ISBN (aka ISBN10) and ISBN13 types were somehow confused...
+ */
+PG_FUNCTION_INFO_V1(isbn_in);
+Datum
+isbn_in(PG_FUNCTION_ARGS)
+{
+ return isbn13_in(PG_FUNCTION_ARGS_VAR);
+}
+
/* ismn_in
*/
PG_FUNCTION_INFO_V1(ismn_in);
@@ -1032,9 +1065,9 @@ upc_in(PG_FUNCTION_ARGS)
/* casting functions
*/
-PG_FUNCTION_INFO_V1(isbn_cast_from_ean13);
+PG_FUNCTION_INFO_V1(isbn10_cast_from_ean13);
Datum
-isbn_cast_from_ean13(PG_FUNCTION_ARGS)
+isbn10_cast_from_ean13(PG_FUNCTION_ARGS)
{
ean13 val = PG_GETARG_EAN13(0);
ean13 result;
@@ -1044,6 +1077,28 @@ isbn_cast_from_ean13(PG_FUNCTION_ARGS)
PG_RETURN_EAN13(result);
}
+PG_FUNCTION_INFO_V1(isbn13_cast_from_ean13);
+Datum
+isbn13_cast_from_ean13(PG_FUNCTION_ARGS)
+{
+ ean13 val = PG_GETARG_EAN13(0);
+ ean13 result;
+
+ (void) ean2isn(val, false, &result, ISBN13);
+
+ PG_RETURN_EAN13(result);
+}
+
+/* more or less isn 1.0 bug-compatible function,
+ * where ISBN & ISBN13 were confused.
+ */
+PG_FUNCTION_INFO_V1(isbn_cast_from_ean13);
+Datum
+isbn_cast_from_ean13(PG_FUNCTION_ARGS)
+{
+ return isbn13_cast_from_ean13(PG_FUNCTION_ARGS_VAR);
+}
+
PG_FUNCTION_INFO_V1(ismn_cast_from_ean13);
Datum
ismn_cast_from_ean13(PG_FUNCTION_ARGS)
diff --git a/contrib/isn/isn.control b/contrib/isn/isn.control
index cf0b2eb..f71f0bb 100644
--- a/contrib/isn/isn.control
+++ b/contrib/isn/isn.control
@@ -1,5 +1,5 @@
# isn extension
comment = 'data types for international product numbering standards'
-default_version = '1.0'
+default_version = '2.0'
module_pathname = '$libdir/isn'
relocatable = true
diff --git a/contrib/isn/sql/isn.sql b/contrib/isn/sql/isn.sql
new file mode 100644
index 0000000..0f7a557
--- /dev/null
+++ b/contrib/isn/sql/isn.sql
@@ -0,0 +1,104 @@
+--
+-- Test ISN extension
+--
+
+CREATE EXTENSION isn;
+
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+SELECT 'M123456780'::ISMN;
+SELECT '12345670'::ISSN;
+SELECT '9780123456780'::ISBN;
+SELECT '9791234567890'::ISBN13;
+SELECT '0123456789010'::UPC;
+SELECT '1234567890120'::EAN13;
+
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+SELECT '9791234567896'::ISBN; -- not an old book
+SELECT '9771234567898'::ISBN; -- not a book
+SELECT '9791234567896'::ISBN13::ISBN; -- not a an old book
+SELECT '9791234567896'::EAN13::ISBN; -- not a an old book
+SELECT '0123456789012'::ISBN; -- not a book
+
+SELECT '9790123456785'::ISBN13; -- not a book
+SELECT '9771234567898'::ISBN13; -- not a book
+SELECT '9771234567898'::EAN13::ISBN13; -- not a book
+SELECT '0123456789012'::ISBN13; -- not a book
+
+SELECT '9780123456786'::ISMN; -- not music
+SELECT '9771234567898'::ISMN; -- not music
+SELECT '9791234567896'::ISMN; -- not music
+SELECT '0123456789012'::ISMN; -- not music
+
+SELECT '9780123456786'::ISSN; -- not serial
+SELECT '9790123456785'::ISSN; -- not serial
+SELECT '9791234567896'::ISSN; -- not serial
+SELECT '0123456789012'::ISSN; -- not serial
+
+SELECT '9780123456786'::UPC; -- not a product
+SELECT '9771234567898'::UPC; -- not a product
+SELECT '9790123456785'::UPC; -- not a product
+SELECT '9791234567896'::UPC; -- not a product
+SELECT '0123456789012'::UPC; -- not a product
+
+SELECT 'postgresql...'::EAN13;
+SELECT 'postgresql...'::ISBN;
+SELECT 9780123456786::EAN13;
+SELECT 9780123456786::ISBN;
+
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
diff --git a/src/include/fmgr.h b/src/include/fmgr.h
index 808d142..1f39f9a 100644
--- a/src/include/fmgr.h
+++ b/src/include/fmgr.h
@@ -149,6 +149,9 @@ extern void fmgr_info_copy(FmgrInfo *dstinfo, FmgrInfo *srcinfo,
/* Standard parameter list for fmgr-compatible functions */
#define PG_FUNCTION_ARGS FunctionCallInfo fcinfo
+/* the variable name used by PG_FUNCTION_ARGS */
+#define PG_FUNCTION_ARGS_VAR fcinfo
+
/*
* Get collation function should use.
*/
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-07-27 16:03 ` Jeff Janes <jeff.janes@gmail.com>
2015-07-27 16:59 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
1 sibling, 1 reply; 26+ messages in thread
From: Jeff Janes @ 2015-07-27 16:03 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
On Mon, Jul 27, 2015 at 2:15 AM, Fabien COELHO <coelho@cri.ensmp.fr> wrote:
> After some tests, it seems that an upgrade script cannot be provided,
> or I missed something.
>
> Basically version 1.0 was confusing ISBN & ISBN13, and for upgrading the
> ISBN type definition must be modified. However, there is no such thing as
> ALTER TYPE, and trying DROP TYPE/ALTER TYPE is rejected because the type
> belongs to an extension (hey I know that, this is what is being done!).
>
You can't test extension upgrade scripts by running the component
statements at the command line. You have to make an actual dummy upgrade
script and test it via "alter extension ... update ...". When executed in
that context, they are exempted from the rule you are running into. (Or
maybe there is another way that I don't know of).
But I wonder what will happen when you try to drop a type which is in use?
Cheers,
Jeff
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 16:03 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Jeff Janes <jeff.janes@gmail.com>
@ 2015-07-27 16:59 ` Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 0 replies; 26+ messages in thread
From: Fabien COELHO @ 2015-07-27 16:59 UTC (permalink / raw)
To: Jeff Janes <jeff.janes@gmail.com>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
Hello,
>> After some tests, it seems that an upgrade script cannot be provided,
>> or I missed something.
>>
>> Basically version 1.0 was confusing ISBN & ISBN13, and for upgrading the
>> ISBN type definition must be modified. However, there is no such thing as
>> ALTER TYPE, and trying DROP TYPE/ALTER TYPE is rejected because the type
>> belongs to an extension (hey I know that, this is what is being done!).
>
> You can't test extension upgrade scripts by running the component
> statements at the command line. You have to make an actual dummy upgrade
> script and test it via "alter extension ... update ...".
Yep... but I actually tried that.
> When executed in that context, they are exempted from the rule you are
> running into.
With DROP TYPE isbn:
# ALTER EXTENSION isn UPDATE;
ERROR: cannot drop type isbn because other objects depend on it
DETAIL: extension isn depends on type isbn
HINT: Use DROP ... CASCADE to drop the dependent objects too.
With DROP TYPE isbn CASCADE:
# ALTER EXTENSION isn UPDATE;
ERROR: cannot drop extension "isn" because it is being modified
> (Or maybe there is another way that I don't know of).
> But I wonder what will happen when you try to drop a type which is in use?
Probably it should drop the dependent objects recursively, but as isn
depends on isbn we do not want to drop the extension while upgrading it.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-07-27 18:04 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
1 sibling, 2 replies; 26+ messages in thread
From: Alvaro Herrera @ 2015-07-27 18:04 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
Fabien COELHO wrote:
> After some tests, it seems that an upgrade script cannot be provided,
> or I missed something.
>
> Basically version 1.0 was confusing ISBN & ISBN13, and for upgrading the
> ISBN type definition must be modified. However, there is no such thing as
> ALTER TYPE, and trying DROP TYPE/ALTER TYPE is rejected because the type
> belongs to an extension (hey I know that, this is what is being done!).
If I understand this correctly, you need to ALTER EXTENSION .. DROP
(which removes the type from the extension), then drop the type, create
it fresh, then ALTER EXTENSION ADD to put it back.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-07-27 18:34 ` Fabien COELHO <coelho@cri.ensmp.fr>
1 sibling, 0 replies; 26+ messages in thread
From: Fabien COELHO @ 2015-07-27 18:34 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
>> Basically version 1.0 was confusing ISBN & ISBN13, and for upgrading the
>> ISBN type definition must be modified. However, there is no such thing as
>> ALTER TYPE, and trying DROP TYPE/ALTER TYPE is rejected because the type
>> belongs to an extension (hey I know that, this is what is being done!).
>
> If I understand this correctly, you need to ALTER EXTENSION .. DROP
> (which removes the type from the extension), then drop the type, create
> it fresh, then ALTER EXTENSION ADD to put it back.
Ok, so the upgrade script must do that manually, that is what I was
missing. I'll try that. Thanks.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
@ 2015-07-27 21:04 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 1 reply; 26+ messages in thread
From: Fabien COELHO @ 2015-07-27 21:04 UTC (permalink / raw)
To: Alvaro Herrera <alvherre@2ndquadrant.com>; +Cc: Heikki Linnakangas <hlinnaka@iki.fi>; Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs
> If I understand this correctly, you need to ALTER EXTENSION .. DROP
> (which removes the type from the extension), then drop the type, create
> it fresh, then ALTER EXTENSION ADD to put it back.
After some testing with that, I have a conundrum: I would like the update
to *fail* if the user actually uses the isbn type so as not to harm data.
However, when the script is at:
DROP TYPE isbn;
It fails, because the isbn_in & out functions depends on it.
If you try:
DROP FUNCTION isbn_in(cstring);
It fails, because the isbn type depends on it. Sure.
The usual exit strategy is:
DROP TYPE isbn CASCADE;
Which works fine... but as a side effect silently remove ISBN columns that
may exist in user table. I do not think it is a good idea for an extension
update script to do that to a librarian:-)
Bar any idea around this issue, I think that an extension upgrade script
is really unadvisable, and the user should do a dump data, drop extension,
create extension, restore data.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-07-27 21:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-07-28 07:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 1 reply; 26+ messages in thread
From: Tom Lane @ 2015-07-27 21:37 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-bugs
Fabien COELHO <coelho@cri.ensmp.fr> writes:
> The usual exit strategy is:
> DROP TYPE isbn CASCADE;
> Which works fine... but as a side effect silently remove ISBN columns that
> may exist in user table. I do not think it is a good idea for an extension
> update script to do that to a librarian:-)
Certainly.
> Bar any idea around this issue, I think that an extension upgrade script
> is really unadvisable, and the user should do a dump data, drop extension,
> create extension, restore data.
AFAICS, that isn't exactly an improvement. You're telling the user
"if you have an ISBN column, you're screwed, and we are going to make it
as painful as it can possibly be to get out of that situation".
I think we'd be better off trying to migrate to a situation where these
type names all still exist but they all act like ISBN13. I'm not sure
what the stages on that journey are.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-07-28 07:57 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 16:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 26+ messages in thread
From: Fabien COELHO @ 2015-07-28 07:57 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; Heikki Linnakangas <hlinnaka@iki.fi>; pgsql-bugs
> AFAICS, that isn't exactly an improvement. You're telling the user
> "if you have an ISBN column, you're screwed, and we are going to make it
> as painful as it can possibly be to get out of that situation".
>
> I think we'd be better off trying to migrate to a situation where these
> type names all still exist but they all act like ISBN13. I'm not sure
> what the stages on that journey are.
Hmm... This is more or less what the previous version was doing, including
display bugs.
So the attached v3:
- distinguishes internally between ISBN & ISBN13 (so it is clean),
but accepts values of one for the other transparently.
- displays ISBN as ISBN if possible, otherwise they are show as
ISBN13. This fixes the reported bug, and the application would
have to adapt.
- adds regression tests, including expected errors.
The good news is that there is no extension version update, it is just a
behavioral change when ISBN13 numbers are used with the ISBN type.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
isn-fix-3.patch (text/x-diff, 17.8K) download
diff --git a/contrib/isn/Makefile b/contrib/isn/Makefile
index 75c07a8..96aaf35 100644
--- a/contrib/isn/Makefile
+++ b/contrib/isn/Makefile
@@ -6,6 +6,8 @@ EXTENSION = isn
DATA = isn--1.0.sql isn--unpackaged--1.0.sql
PGFILEDESC = "isn - data types for international product numbering standards"
+REGRESS = isn
+
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/isn/expected/isn.out b/contrib/isn/expected/isn.out
new file mode 100644
index 0000000..0e259d2
--- /dev/null
+++ b/contrib/isn/expected/isn.out
@@ -0,0 +1,222 @@
+--
+-- Test ISN extension
+--
+CREATE EXTENSION isn;
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+ ean13 | ean13 | ean13 | ean13 | ean13 | ean13
+-------------------+-------------------+-----------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 979-0-1234-5678-5 | 979-123456789-6 | 977-1234-567-89-8 | 012-345678901-2 | 123-456789012-8
+(1 row)
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+ isbn | isbn | isbn | isbn
+---------------+---------------+---------------+---------------
+ 0-12-345678-9 | 1-234-56789-X | 0-12-345678-9 | 0-12-345678-9
+(1 row)
+
+SELECT -- new books, shown as ISBN13 even for ISBN...
+ '9791234567896'::ISBN,
+ '9791234567896'::ISBN13::ISBN,
+ '9791234567896'::EAN13::ISBN;
+ isbn | isbn | isbn
+-----------------+-----------------+-----------------
+ 979-123456789-6 | 979-123456789-6 | 979-123456789-6
+(1 row)
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+ isbn13 | isbn13 | isbn13 | isbn13
+-------------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 978-1-234-56789-7 | 979-123456789-6 | 979-123456789-6
+(1 row)
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+ ismn | ismn | ismn | ismn
+---------------+---------------+---------------+---------------
+ M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5
+(1 row)
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+ ismn13 | ismn13 | ismn13
+-------------------+-------------------+-------------------
+ 979-0-1234-5678-5 | 979-0-1234-5678-5 | 979-0-1234-5678-5
+(1 row)
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+ issn | issn
+-----------+-----------
+ 1234-5679 | 1234-5679
+(1 row)
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+ issn13 | issn13 | issn13 | issn13
+-------------------+-------------------+-------------------+-------------------
+ 977-1234-567-00-3 | 977-1234-567-00-3 | 977-1234-567-89-8 | 977-1234-567-89-8
+(1 row)
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+ upc | upc
+--------------+--------------
+ 123456789012 | 123456789012
+(1 row)
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+ERROR: invalid check digit for ISBN13 number: "1234567890", should be X
+LINE 1: SELECT '1234567890'::ISBN;
+ ^
+SELECT 'M123456780'::ISMN;
+ERROR: invalid check digit for ISMN number: "M123456780", should be 5
+LINE 1: SELECT 'M123456780'::ISMN;
+ ^
+SELECT '12345670'::ISSN;
+ERROR: invalid check digit for ISSN number: "12345670", should be 9
+LINE 1: SELECT '12345670'::ISSN;
+ ^
+SELECT '9780123456780'::ISBN;
+ERROR: invalid check digit for ISBN13 number: "9780123456780", should be 6
+LINE 1: SELECT '9780123456780'::ISBN;
+ ^
+SELECT '9791234567890'::ISBN13;
+ERROR: invalid check digit for ISBN13 number: "9791234567890", should be 6
+LINE 1: SELECT '9791234567890'::ISBN13;
+ ^
+SELECT '0123456789010'::UPC;
+ERROR: invalid check digit for UPC number: "0123456789010", should be 2
+LINE 1: SELECT '0123456789010'::UPC;
+ ^
+SELECT '1234567890120'::EAN13;
+ERROR: invalid check digit for EAN13 number: "1234567890120", should be 8
+LINE 1: SELECT '1234567890120'::EAN13;
+ ^
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+ERROR: cannot cast ISMN to ISBN13 for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN;
+ ^
+SELECT '9771234567898'::ISBN; -- not a book
+ERROR: cannot cast ISSN to ISBN13 for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN;
+ ^
+SELECT '0123456789012'::ISBN; -- not a book
+ERROR: cannot cast UPC to ISBN13 for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN;
+ ^
+SELECT '9790123456785'::ISBN13; -- not a book
+ERROR: cannot cast ISMN to ISBN13 for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN13;
+ ^
+SELECT '9771234567898'::ISBN13; -- not a book
+ERROR: cannot cast ISSN to ISBN13 for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN13;
+ ^
+SELECT '0123456789012'::ISBN13; -- not a book
+ERROR: cannot cast UPC to ISBN13 for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN13;
+ ^
+SELECT '9780123456786'::ISMN; -- not music
+ERROR: cannot cast ISBN to ISMN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISMN;
+ ^
+SELECT '9771234567898'::ISMN; -- not music
+ERROR: cannot cast ISSN to ISMN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISMN;
+ ^
+SELECT '9791234567896'::ISMN; -- not music
+ERROR: cannot cast ISBN13 to ISMN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISMN;
+ ^
+SELECT '0123456789012'::ISMN; -- not music
+ERROR: cannot cast UPC to ISMN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISMN;
+ ^
+SELECT '9780123456786'::ISSN; -- not serial
+ERROR: cannot cast ISBN to ISSN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISSN;
+ ^
+SELECT '9790123456785'::ISSN; -- not serial
+ERROR: cannot cast ISMN to ISSN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISSN;
+ ^
+SELECT '9791234567896'::ISSN; -- not serial
+ERROR: cannot cast ISBN13 to ISSN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISSN;
+ ^
+SELECT '0123456789012'::ISSN; -- not serial
+ERROR: cannot cast UPC to ISSN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISSN;
+ ^
+SELECT '9780123456786'::UPC; -- not a product
+ERROR: cannot cast ISBN to UPC for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::UPC;
+ ^
+SELECT '9771234567898'::UPC; -- not a product
+ERROR: cannot cast ISSN to UPC for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::UPC;
+ ^
+SELECT '9790123456785'::UPC; -- not a product
+ERROR: cannot cast ISMN to UPC for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::UPC;
+ ^
+SELECT '9791234567896'::UPC; -- not a product
+ERROR: cannot cast ISBN13 to UPC for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::UPC;
+ ^
+SELECT 'postgresql...'::EAN13;
+ERROR: invalid input syntax for EAN13 number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::EAN13;
+ ^
+SELECT 'postgresql...'::ISBN;
+ERROR: invalid input syntax for ISBN13 number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::ISBN;
+ ^
+SELECT 9780123456786::EAN13;
+ERROR: cannot cast type bigint to ean13
+LINE 1: SELECT 9780123456786::EAN13;
+ ^
+SELECT 9780123456786::ISBN;
+ERROR: cannot cast type bigint to isbn
+LINE 1: SELECT 9780123456786::ISBN;
+ ^
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+ ok | ok | nope
+----+----+------
+ t | t | t
+(1 row)
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c
index 4039824..04cc9f6 100644
--- a/contrib/isn/isn.c
+++ b/contrib/isn/isn.c
@@ -30,10 +30,14 @@ PG_MODULE_MAGIC;
enum isn_type
{
- INVALID, ANY, EAN13, ISBN, ISMN, ISSN, UPC
+ /* ISBN is ISBN13 with an adaptative display */
+ INVALID, ANY, EAN13, ISBN13, ISBN, ISMN, ISSN, UPC
};
-static const char *const isn_names[] = {"EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN", "ISMN", "ISSN", "UPC"};
+static const char *const isn_names[] = {
+ "EAN13/UPC/ISxN", "EAN13/UPC/ISxN", "EAN13", "ISBN13",
+ "ISBN", "ISMN", "ISSN", "UPC"
+};
static bool g_weak = false;
static bool g_initialized = false;
@@ -366,7 +370,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
/* find out the data type: */
if (strncmp("978", buf, 3) == 0)
- { /* ISBN */
+ { /* ISBN or ISBN-13 */
type = ISBN;
}
else if (strncmp("977", buf, 3) == 0)
@@ -379,7 +383,7 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
}
else if (strncmp("979", buf, 3) == 0)
{ /* ISBN-13 */
- type = ISBN;
+ type = ISBN13;
}
else if (*buf == '0')
{ /* UPC */
@@ -389,7 +393,10 @@ ean2isn(ean13 ean, bool errorOK, ean13 *result, enum isn_type accept)
{
type = EAN13;
}
- if (accept != ANY && accept != EAN13 && accept != type)
+ if (accept != ANY && accept != EAN13 && accept != type &&
+ /* also accept ISBN13 as ISBN... */
+ !((accept == ISBN13 && type == ISBN) ||
+ (accept == ISBN && type == ISBN13)))
goto eanwrongtype;
*result = ret;
@@ -443,16 +450,22 @@ ean2ISBN(char *isn)
char *aux;
unsigned check;
- /* the number should come in this format: 978-0-000-00000-0 */
- /* Strip the first part and calculate the new check digit */
- hyphenate(isn, isn + 4, NULL, NULL);
- check = weight_checkdig(isn, 10);
- aux = strchr(isn, '\0');
- while (!isdigit((unsigned char) *--aux));
- if (check == 10)
- *aux = 'X';
- else
- *aux = check + '0';
+ /* the number should come in this format: 978-0-000-00000-0
+ * or may be an ISBN13 number...
+ * Do the short output version only if possible.
+ */
+ if (strncmp("978-", isn, 4) == 0)
+ {
+ /* Strip the first part and calculate the new check digit */
+ hyphenate(isn, isn + 4, NULL, NULL);
+ check = weight_checkdig(isn, 10);
+ aux = strchr(isn, '\0');
+ while (!isdigit((unsigned char) *--aux));
+ if (check == 10)
+ *aux = 'X';
+ else
+ *aux = check + '0';
+ }
}
static inline void
@@ -516,7 +529,8 @@ str2ean(const char *num)
* the string (maximum MAXEAN13LEN+1 bytes)
* This doesn't verify for a valid check digit.
*
- * If shortType is true, the returned string is in the old ISxN short format.
+ * If shortType is true, the returned string is in the old ISxN short format
+ * if possible, otherwise it is kept as a ISxN13 number.
* If errorOK is false, ereport a useful error message if the string is bad.
* If errorOK is true, just return "false" for bad input.
*/
@@ -571,7 +585,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
/* find out what type of hyphenation is needed: */
if (strncmp("978-", result, search) == 0)
- { /* ISBN -13 978-range */
+ { /* ISBN-13 978-range */
/* The string should be in this form: 978-??000000000-0" */
type = ISBN;
TABLE = ISBN_range;
@@ -594,7 +608,7 @@ ean2string(ean13 ean, bool errorOK, char *result, bool shortType)
else if (strncmp("979-", result, search) == 0)
{ /* ISBN-13 979-range */
/* The string should be in this form: 979-??000000000-0" */
- type = ISBN;
+ type = ISBN13;
TABLE = ISBN_range_new;
TABLE_index = ISBN_index_new;
}
@@ -628,6 +642,8 @@ okay:
if (shortType)
switch (type)
{
+ case ISBN13: /* yep, accept ISBN13 number as short type... */
+ break;
case ISBN:
ean2ISBN(result);
break;
@@ -804,7 +820,10 @@ string2ean(const char *str, bool errorOK, ean13 *result,
/* obtain the real check digit value, validate, and convert to ean13: */
if (accept == EAN13 && type != accept)
goto eanwrongtype;
- if (accept != ANY && type != EAN13 && type != accept)
+ if (accept != ANY && type != EAN13 && type != accept &&
+ /* yep, accept ISBN13 as ISBN... */
+ !((accept == ISBN13 && type == ISBN) ||
+ (accept == ISBN && type == ISBN13)))
goto eanwrongtype;
switch (type)
{
@@ -816,12 +835,15 @@ string2ean(const char *str, bool errorOK, ean13 *result,
else if (strncmp("977", buf + 3, 3) == 0)
type = ISSN;
else if (strncmp("978", buf + 3, 3) == 0)
- type = ISBN;
+ type = ISBN; /* or ISBN13 */
else if (strncmp("9790", buf + 3, 4) == 0)
type = ISMN;
else if (strncmp("979", buf + 3, 3) == 0)
- type = ISBN;
- if (accept != EAN13 && accept != ANY && type != accept)
+ type = ISBN13;
+ if (accept != EAN13 && accept != ANY && type != accept &&
+ /* yep, ISBN accepts ISBN13 numbers... */
+ !((accept == ISBN13 && type == ISBN) ||
+ (accept == ISBN && type == ISBN13)))
goto eanwrongtype;
break;
case ISMN:
@@ -978,7 +1000,7 @@ ean13_in(PG_FUNCTION_ARGS)
PG_RETURN_EAN13(result);
}
-/* isbn_in
+/* accept *ANY* isbn or isbn13 type
*/
PG_FUNCTION_INFO_V1(isbn_in);
Datum
@@ -987,7 +1009,7 @@ isbn_in(PG_FUNCTION_ARGS)
const char *str = PG_GETARG_CSTRING(0);
ean13 result;
- (void) string2ean(str, false, &result, ISBN);
+ (void) string2ean(str, false, &result, ISBN13);
PG_RETURN_EAN13(result);
}
@@ -1030,8 +1052,8 @@ upc_in(PG_FUNCTION_ARGS)
PG_RETURN_EAN13(result);
}
-/* casting functions
-*/
+/* anything which is a book, ISBN or ISBN13, is accepted.
+ */
PG_FUNCTION_INFO_V1(isbn_cast_from_ean13);
Datum
isbn_cast_from_ean13(PG_FUNCTION_ARGS)
@@ -1039,7 +1061,7 @@ isbn_cast_from_ean13(PG_FUNCTION_ARGS)
ean13 val = PG_GETARG_EAN13(0);
ean13 result;
- (void) ean2isn(val, false, &result, ISBN);
+ (void) ean2isn(val, false, &result, ISBN13);
PG_RETURN_EAN13(result);
}
diff --git a/contrib/isn/sql/isn.sql b/contrib/isn/sql/isn.sql
new file mode 100644
index 0000000..5ef6d8a
--- /dev/null
+++ b/contrib/isn/sql/isn.sql
@@ -0,0 +1,104 @@
+--
+-- Test ISN extension
+--
+
+CREATE EXTENSION isn;
+
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+
+SELECT -- new books, shown as ISBN13 even for ISBN...
+ '9791234567896'::ISBN,
+ '9791234567896'::ISBN13::ISBN,
+ '9791234567896'::EAN13::ISBN;
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+SELECT 'M123456780'::ISMN;
+SELECT '12345670'::ISSN;
+SELECT '9780123456780'::ISBN;
+SELECT '9791234567890'::ISBN13;
+SELECT '0123456789010'::UPC;
+SELECT '1234567890120'::EAN13;
+
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+SELECT '9771234567898'::ISBN; -- not a book
+SELECT '0123456789012'::ISBN; -- not a book
+
+SELECT '9790123456785'::ISBN13; -- not a book
+SELECT '9771234567898'::ISBN13; -- not a book
+SELECT '0123456789012'::ISBN13; -- not a book
+
+SELECT '9780123456786'::ISMN; -- not music
+SELECT '9771234567898'::ISMN; -- not music
+SELECT '9791234567896'::ISMN; -- not music
+SELECT '0123456789012'::ISMN; -- not music
+
+SELECT '9780123456786'::ISSN; -- not serial
+SELECT '9790123456785'::ISSN; -- not serial
+SELECT '9791234567896'::ISSN; -- not serial
+SELECT '0123456789012'::ISSN; -- not serial
+
+SELECT '9780123456786'::UPC; -- not a product
+SELECT '9771234567898'::UPC; -- not a product
+SELECT '9790123456785'::UPC; -- not a product
+SELECT '9791234567896'::UPC; -- not a product
+
+SELECT 'postgresql...'::EAN13;
+SELECT 'postgresql...'::ISBN;
+SELECT 9780123456786::EAN13;
+SELECT 9780123456786::ISBN;
+
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-07-28 07:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-08-02 16:57 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 17:18 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 1 reply; 26+ messages in thread
From: Heikki Linnakangas @ 2015-08-02 16:57 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
On 07/28/2015 10:57 AM, Fabien COELHO wrote:
>
>> AFAICS, that isn't exactly an improvement. You're telling the user
>> "if you have an ISBN column, you're screwed, and we are going to make it
>> as painful as it can possibly be to get out of that situation".
>>
>> I think we'd be better off trying to migrate to a situation where these
>> type names all still exist but they all act like ISBN13. I'm not sure
>> what the stages on that journey are.
>
> Hmm... This is more or less what the previous version was doing, including
> display bugs.
>
> So the attached v3:
> - distinguishes internally between ISBN & ISBN13 (so it is clean),
> but accepts values of one for the other transparently.
> - displays ISBN as ISBN if possible, otherwise they are show as
> ISBN13. This fixes the reported bug, and the application would
> have to adapt.
> - adds regression tests, including expected errors.
>
> The good news is that there is no extension version update, it is just a
> behavioral change when ISBN13 numbers are used with the ISBN type.
Hmm, I don't think we need or want the separate ISBN and ISBN13 codes
internally. They're used interchangeably, anyway. If we just apply your
change to ean2ISBN(), we're done. Per the attached.
Thanks for the regression tests, that was very badly needed!
- Heikki
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Attachments:
isn-fix-heikki-4.patch (application/x-patch, 12.4K) download
diff --git a/contrib/isn/Makefile b/contrib/isn/Makefile
index 75c07a8..96aaf35 100644
--- a/contrib/isn/Makefile
+++ b/contrib/isn/Makefile
@@ -6,6 +6,8 @@ EXTENSION = isn
DATA = isn--1.0.sql isn--unpackaged--1.0.sql
PGFILEDESC = "isn - data types for international product numbering standards"
+REGRESS = isn
+
ifdef USE_PGXS
PG_CONFIG = pg_config
PGXS := $(shell $(PG_CONFIG) --pgxs)
diff --git a/contrib/isn/expected/isn.out b/contrib/isn/expected/isn.out
new file mode 100644
index 0000000..140bc86
--- /dev/null
+++ b/contrib/isn/expected/isn.out
@@ -0,0 +1,222 @@
+--
+-- Test ISN extension
+--
+CREATE EXTENSION isn;
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+ ean13 | ean13 | ean13 | ean13 | ean13 | ean13
+-------------------+-------------------+-----------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 979-0-1234-5678-5 | 979-123456789-6 | 977-1234-567-89-8 | 012-345678901-2 | 123-456789012-8
+(1 row)
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+ isbn | isbn | isbn | isbn
+---------------+---------------+---------------+---------------
+ 0-12-345678-9 | 1-234-56789-X | 0-12-345678-9 | 0-12-345678-9
+(1 row)
+
+SELECT -- new books, shown as ISBN13 even for ISBN...
+ '9791234567896'::ISBN,
+ '9791234567896'::ISBN13::ISBN,
+ '9791234567896'::EAN13::ISBN;
+ isbn | isbn | isbn
+-----------------+-----------------+-----------------
+ 979-123456789-6 | 979-123456789-6 | 979-123456789-6
+(1 row)
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+ isbn13 | isbn13 | isbn13 | isbn13
+-------------------+-------------------+-----------------+-----------------
+ 978-0-12-345678-6 | 978-1-234-56789-7 | 979-123456789-6 | 979-123456789-6
+(1 row)
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+ ismn | ismn | ismn | ismn
+---------------+---------------+---------------+---------------
+ M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5 | M-1234-5678-5
+(1 row)
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+ ismn13 | ismn13 | ismn13
+-------------------+-------------------+-------------------
+ 979-0-1234-5678-5 | 979-0-1234-5678-5 | 979-0-1234-5678-5
+(1 row)
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+ issn | issn
+-----------+-----------
+ 1234-5679 | 1234-5679
+(1 row)
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+ issn13 | issn13 | issn13 | issn13
+-------------------+-------------------+-------------------+-------------------
+ 977-1234-567-00-3 | 977-1234-567-00-3 | 977-1234-567-89-8 | 977-1234-567-89-8
+(1 row)
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+ upc | upc
+--------------+--------------
+ 123456789012 | 123456789012
+(1 row)
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+ERROR: invalid check digit for ISBN number: "1234567890", should be X
+LINE 1: SELECT '1234567890'::ISBN;
+ ^
+SELECT 'M123456780'::ISMN;
+ERROR: invalid check digit for ISMN number: "M123456780", should be 5
+LINE 1: SELECT 'M123456780'::ISMN;
+ ^
+SELECT '12345670'::ISSN;
+ERROR: invalid check digit for ISSN number: "12345670", should be 9
+LINE 1: SELECT '12345670'::ISSN;
+ ^
+SELECT '9780123456780'::ISBN;
+ERROR: invalid check digit for ISBN number: "9780123456780", should be 6
+LINE 1: SELECT '9780123456780'::ISBN;
+ ^
+SELECT '9791234567890'::ISBN13;
+ERROR: invalid check digit for ISBN number: "9791234567890", should be 6
+LINE 1: SELECT '9791234567890'::ISBN13;
+ ^
+SELECT '0123456789010'::UPC;
+ERROR: invalid check digit for UPC number: "0123456789010", should be 2
+LINE 1: SELECT '0123456789010'::UPC;
+ ^
+SELECT '1234567890120'::EAN13;
+ERROR: invalid check digit for EAN13 number: "1234567890120", should be 8
+LINE 1: SELECT '1234567890120'::EAN13;
+ ^
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+ERROR: cannot cast ISMN to ISBN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN;
+ ^
+SELECT '9771234567898'::ISBN; -- not a book
+ERROR: cannot cast ISSN to ISBN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN;
+ ^
+SELECT '0123456789012'::ISBN; -- not a book
+ERROR: cannot cast UPC to ISBN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN;
+ ^
+SELECT '9790123456785'::ISBN13; -- not a book
+ERROR: cannot cast ISMN to ISBN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISBN13;
+ ^
+SELECT '9771234567898'::ISBN13; -- not a book
+ERROR: cannot cast ISSN to ISBN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISBN13;
+ ^
+SELECT '0123456789012'::ISBN13; -- not a book
+ERROR: cannot cast UPC to ISBN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISBN13;
+ ^
+SELECT '9780123456786'::ISMN; -- not music
+ERROR: cannot cast ISBN to ISMN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISMN;
+ ^
+SELECT '9771234567898'::ISMN; -- not music
+ERROR: cannot cast ISSN to ISMN for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::ISMN;
+ ^
+SELECT '9791234567896'::ISMN; -- not music
+ERROR: cannot cast ISBN to ISMN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISMN;
+ ^
+SELECT '0123456789012'::ISMN; -- not music
+ERROR: cannot cast UPC to ISMN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISMN;
+ ^
+SELECT '9780123456786'::ISSN; -- not serial
+ERROR: cannot cast ISBN to ISSN for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::ISSN;
+ ^
+SELECT '9790123456785'::ISSN; -- not serial
+ERROR: cannot cast ISMN to ISSN for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::ISSN;
+ ^
+SELECT '9791234567896'::ISSN; -- not serial
+ERROR: cannot cast ISBN to ISSN for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::ISSN;
+ ^
+SELECT '0123456789012'::ISSN; -- not serial
+ERROR: cannot cast UPC to ISSN for number: "0123456789012"
+LINE 1: SELECT '0123456789012'::ISSN;
+ ^
+SELECT '9780123456786'::UPC; -- not a product
+ERROR: cannot cast ISBN to UPC for number: "9780123456786"
+LINE 1: SELECT '9780123456786'::UPC;
+ ^
+SELECT '9771234567898'::UPC; -- not a product
+ERROR: cannot cast ISSN to UPC for number: "9771234567898"
+LINE 1: SELECT '9771234567898'::UPC;
+ ^
+SELECT '9790123456785'::UPC; -- not a product
+ERROR: cannot cast ISMN to UPC for number: "9790123456785"
+LINE 1: SELECT '9790123456785'::UPC;
+ ^
+SELECT '9791234567896'::UPC; -- not a product
+ERROR: cannot cast ISBN to UPC for number: "9791234567896"
+LINE 1: SELECT '9791234567896'::UPC;
+ ^
+SELECT 'postgresql...'::EAN13;
+ERROR: invalid input syntax for EAN13 number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::EAN13;
+ ^
+SELECT 'postgresql...'::ISBN;
+ERROR: invalid input syntax for ISBN number: "postgresql..."
+LINE 1: SELECT 'postgresql...'::ISBN;
+ ^
+SELECT 9780123456786::EAN13;
+ERROR: cannot cast type bigint to ean13
+LINE 1: SELECT 9780123456786::EAN13;
+ ^
+SELECT 9780123456786::ISBN;
+ERROR: cannot cast type bigint to isbn
+LINE 1: SELECT 9780123456786::ISBN;
+ ^
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+ ok | ok | nope
+----+----+------
+ t | t | t
+(1 row)
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
diff --git a/contrib/isn/isn.c b/contrib/isn/isn.c
index 4039824..f4bb397 100644
--- a/contrib/isn/isn.c
+++ b/contrib/isn/isn.c
@@ -443,16 +443,22 @@ ean2ISBN(char *isn)
char *aux;
unsigned check;
- /* the number should come in this format: 978-0-000-00000-0 */
- /* Strip the first part and calculate the new check digit */
- hyphenate(isn, isn + 4, NULL, NULL);
- check = weight_checkdig(isn, 10);
- aux = strchr(isn, '\0');
- while (!isdigit((unsigned char) *--aux));
- if (check == 10)
- *aux = 'X';
- else
- *aux = check + '0';
+ /* the number should come in this format: 978-0-000-00000-0
+ * or may be an ISBN13 number...
+ * Do the short output version only if possible.
+ */
+ if (strncmp("978-", isn, 4) == 0)
+ {
+ /* Strip the first part and calculate the new check digit */
+ hyphenate(isn, isn + 4, NULL, NULL);
+ check = weight_checkdig(isn, 10);
+ aux = strchr(isn, '\0');
+ while (!isdigit((unsigned char) *--aux));
+ if (check == 10)
+ *aux = 'X';
+ else
+ *aux = check + '0';
+ }
}
static inline void
diff --git a/contrib/isn/sql/isn.sql b/contrib/isn/sql/isn.sql
new file mode 100644
index 0000000..5ef6d8a
--- /dev/null
+++ b/contrib/isn/sql/isn.sql
@@ -0,0 +1,104 @@
+--
+-- Test ISN extension
+--
+
+CREATE EXTENSION isn;
+
+--
+-- test valid conversions
+--
+SELECT '9780123456786'::EAN13, -- old book
+ '9790123456785'::EAN13, -- music
+ '9791234567896'::EAN13, -- new book
+ '9771234567898'::EAN13, -- serial
+ '0123456789012'::EAN13, -- upc
+ '1234567890128'::EAN13;
+
+SELECT '9780123456786'::ISBN,
+ '123456789X'::ISBN,
+ '9780123456786'::ISBN13::ISBN,
+ '9780123456786'::EAN13::ISBN;
+
+SELECT -- new books, shown as ISBN13 even for ISBN...
+ '9791234567896'::ISBN,
+ '9791234567896'::ISBN13::ISBN,
+ '9791234567896'::EAN13::ISBN;
+
+SELECT '9780123456786'::ISBN13,
+ '123456789X'::ISBN13,
+ '9791234567896'::ISBN13,
+ '9791234567896'::EAN13::ISBN13;
+
+SELECT '9790123456785'::ISMN,
+ '9790123456785'::EAN13::ISMN,
+ 'M123456785'::ISMN,
+ 'M-1234-5678-5'::ISMN;
+
+SELECT '9790123456785'::ISMN13,
+ 'M123456785'::ISMN13,
+ 'M-1234-5678-5'::ISMN13;
+
+SELECT '9771234567003'::ISSN,
+ '12345679'::ISSN;
+
+SELECT '9771234567003'::ISSN13,
+ '12345679'::ISSN13,
+ '9771234567898'::ISSN13,
+ '9771234567898'::EAN13::ISSN13;
+
+SELECT '0123456789012'::UPC,
+ '0123456789012'::EAN13::UPC;
+
+--
+-- test invalid checksums
+--
+SELECT '1234567890'::ISBN;
+SELECT 'M123456780'::ISMN;
+SELECT '12345670'::ISSN;
+SELECT '9780123456780'::ISBN;
+SELECT '9791234567890'::ISBN13;
+SELECT '0123456789010'::UPC;
+SELECT '1234567890120'::EAN13;
+
+--
+-- test invalid conversions
+--
+SELECT '9790123456785'::ISBN; -- not a book
+SELECT '9771234567898'::ISBN; -- not a book
+SELECT '0123456789012'::ISBN; -- not a book
+
+SELECT '9790123456785'::ISBN13; -- not a book
+SELECT '9771234567898'::ISBN13; -- not a book
+SELECT '0123456789012'::ISBN13; -- not a book
+
+SELECT '9780123456786'::ISMN; -- not music
+SELECT '9771234567898'::ISMN; -- not music
+SELECT '9791234567896'::ISMN; -- not music
+SELECT '0123456789012'::ISMN; -- not music
+
+SELECT '9780123456786'::ISSN; -- not serial
+SELECT '9790123456785'::ISSN; -- not serial
+SELECT '9791234567896'::ISSN; -- not serial
+SELECT '0123456789012'::ISSN; -- not serial
+
+SELECT '9780123456786'::UPC; -- not a product
+SELECT '9771234567898'::UPC; -- not a product
+SELECT '9790123456785'::UPC; -- not a product
+SELECT '9791234567896'::UPC; -- not a product
+
+SELECT 'postgresql...'::EAN13;
+SELECT 'postgresql...'::ISBN;
+SELECT 9780123456786::EAN13;
+SELECT 9780123456786::ISBN;
+
+--
+-- test some comparisons, must yield true
+--
+SELECT '12345679'::ISSN = '9771234567003'::EAN13 AS "ok",
+ 'M-1234-5678-5'::ISMN = '9790123456785'::EAN13 AS "ok",
+ '9791234567896'::EAN13 != '123456789X'::ISBN AS "nope";
+
+--
+-- cleanup
+--
+DROP EXTENSION isn;
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-07-28 07:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 16:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-08-02 17:18 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 18:42 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 26+ messages in thread
From: Fabien COELHO @ 2015-08-02 17:18 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
> [...]
>
> Hmm, I don't think we need or want the separate ISBN and ISBN13 codes
> internally. They're used interchangeably, anyway. If we just apply your
> change to ean2ISBN(), we're done. Per the attached.
The simpler the better. Works for me.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-07-28 07:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 16:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 17:18 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
@ 2015-08-02 18:42 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 19:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 26+ messages in thread
From: Heikki Linnakangas @ 2015-08-02 18:42 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
On 08/02/2015 08:18 PM, Fabien COELHO wrote:
>
>> [...]
>>
>> Hmm, I don't think we need or want the separate ISBN and ISBN13 codes
>> internally. They're used interchangeably, anyway. If we just apply your
>> change to ean2ISBN(), we're done. Per the attached.
>
> The simpler the better. Works for me.
Ok, committed. Thanks!
- Heikki
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-07-28 07:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 16:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 17:18 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 18:42 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
@ 2015-08-02 19:04 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-08-02 19:17 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 26+ messages in thread
From: Tom Lane @ 2015-08-02 19:04 UTC (permalink / raw)
To: Heikki Linnakangas <hlinnaka@iki.fi>; +Cc: Fabien COELHO <coelho@cri.ensmp.fr>; Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
Heikki Linnakangas <hlinnaka@iki.fi> writes:
> On 08/02/2015 08:18 PM, Fabien COELHO wrote:
>> The simpler the better. Works for me.
> Ok, committed. Thanks!
I guess you forgot "git push"?
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-27 09:15 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 21:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
2015-07-28 07:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 16:57 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 17:18 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 18:42 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 19:04 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-08-02 19:17 ` Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 0 replies; 26+ messages in thread
From: Heikki Linnakangas @ 2015-08-02 19:17 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Fabien COELHO <coelho@cri.ensmp.fr>; Alvaro Herrera <alvherre@2ndquadrant.com>; pgsql-bugs
On 08/02/2015 10:04 PM, Tom Lane wrote:
> Heikki Linnakangas <hlinnaka@iki.fi> writes:
>> On 08/02/2015 08:18 PM, Fabien COELHO wrote:
>>> The simpler the better. Works for me.
>
>> Ok, committed. Thanks!
>
> I guess you forgot "git push"?
Yep, pushed now for real.
- Heikki
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Tom Lane <tgl@sss.pgh.pa.us>
@ 2015-06-15 22:47 ` Peter Geoghegan <pg@heroku.com>
1 sibling, 0 replies; 26+ messages in thread
From: Peter Geoghegan @ 2015-06-15 22:47 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On Mon, Jun 15, 2015 at 10:26 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> I poked at this a little bit. I think the issue may be that this bit
> at line 832 in isn.c:
>
> case ISBN:
> memcpy(buf, "978", 3);
>
> supposes that all ISBNs should have prefix 978, whereas your example is
> using prefix 979, which seems to be also valid according to code a few
> lines above.
I actually didn't realize that the ISBN type assumed the "bookland"
country code, which is 978. That's terrible, and is really a distinct
way that the type is broken (distinct from the range enforcement
misfeature that I always go on about).
I was planning on suggesting completely removing any enforcement of
ISBN ranges by the ISBN type. We could then rely entirely on the check
digit, which has virtually no disadvantage relative to "more complete"
enforcement. But even that's not going to help here, because the ISBN
output function doesn't show the country code or the check digit:
postgres=# select '978-0-393-04002-9'::isbn;
isbn
---------------
0-393-04002-X
(1 row)
--
Peter Geoghegan
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
@ 2015-06-15 19:43 B.Z <joejob357@gmail.com>
2015-06-15 20:02 ` Re: BUG #13442: ISBN doesn't always roundtrip with text Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 1 reply; 26+ messages in thread
From: B.Z @ 2015-06-15 19:43 UTC (permalink / raw)
To: Fabien COELHO <coelho@cri.ensmp.fr>; +Cc: pgsql-bugs
(I'm the original reporter).
I think this gets to the crux of the matter, although I disagree that no
bug exists.
ISBN10s, i.e. 10-digit ISBNs, can be converted to ISBN13s, and back again.
i.e. they round-trip. ISBN13s with the 979 prefix can't be converted to
ISBN10s. (Evidence includes http://pcn.loc.gov/isbncnvt.html failing on
ISBN13s with 979- prefixes with "This 13-digit ISBN does not begin with
"978"
It cannot be converted to a 10-digit ISBN.", and
https://247pearsoned.custhelp.com/app/answers/detail/a_id/6922/~/isbn-converter
stating "The revised ISBN standard does not provide rules for converting or
assigning 10-digit ISBNs to 13-digit ISBNs prefixed with "979". There is no
industry approved method for converting ISBN-13s prefixed with "979" to an
ISBN-10. Thirteen-digit ISBNs prefixed with "979" should not be represented
to trading partners as 10-digit ISBNs. ").
The key bug, then, is that the isn extension attempts to make this illegal
conversion:
select '9791020902573'::isbn; --gives 10-209-0257-4
I suspect the correct behaviour is raising an exception in these
circumstances.
^ permalink raw reply [nested|flat] 26+ messages in thread
* Re: BUG #13442: ISBN doesn't always roundtrip with text
2015-06-15 19:43 Re: BUG #13442: ISBN doesn't always roundtrip with text B.Z <joejob357@gmail.com>
@ 2015-06-15 20:02 ` Fabien COELHO <coelho@cri.ensmp.fr>
0 siblings, 0 replies; 26+ messages in thread
From: Fabien COELHO @ 2015-06-15 20:02 UTC (permalink / raw)
To: B.Z <joejob357@gmail.com>; +Cc: pgsql-bugs
> The key bug, then, is that the isn extension attempts to make this illegal
> conversion:
>
> select '9791020902573'::isbn; --gives 10-209-0257-4
Indeed, this one looks like a bug, it should really be an error.
--
Fabien.
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 26+ messages in thread
end of thread, other threads:[~2015-08-02 19:17 UTC | newest]
Thread overview: 26+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-06-14 15:59 BUG #13442: ISBN doesn't always roundtrip with text bz@mailinator.com
2015-06-15 17:26 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-06-15 18:34 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 03:35 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-06-16 05:37 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-16 06:09 ` David G. Johnston <david.g.johnston@gmail.com>
2015-06-16 08:05 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-06-20 07:04 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-21 08:45 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-07-21 14:17 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 09:15 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 16:03 ` Jeff Janes <jeff.janes@gmail.com>
2015-07-27 16:59 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 18:04 ` Alvaro Herrera <alvherre@2ndquadrant.com>
2015-07-27 18:34 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:04 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-07-27 21:37 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-07-28 07:57 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 16:57 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 17:18 ` Fabien COELHO <coelho@cri.ensmp.fr>
2015-08-02 18:42 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-08-02 19:04 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-08-02 19:17 ` Heikki Linnakangas <hlinnaka@iki.fi>
2015-06-15 22:47 ` Peter Geoghegan <pg@heroku.com>
2015-06-15 19:43 Re: BUG #13442: ISBN doesn't always roundtrip with text B.Z <joejob357@gmail.com>
2015-06-15 20:02 ` Fabien COELHO <coelho@cri.ensmp.fr>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox