Hello all,
i'm playing around with the isn contrib module and ran into an
annoying problem. The module defines an is_valid() function which
obviously is intended to check the validity of an ISBN number. Makes
sense to have such a function because if the user mistyped the number
the application can raise an error.
Now it seems that instead of the application PostgreSQL is raising the
error:
test=# select is_valid('978-3-937514-69-7'::isbn13);is_valid
----------t
(1 row)
test=# select is_valid('978-3-937514-69-6'::isbn13);
ERROR: invalid check digit for ISBN number: "978-3-937514-69-6",
should be 7 ROW 1: select is_valid('978-3-937514-69-6'::isbn13); ^
The first ISBN is valid and the validator function returns 't', that's
fine. The second ISBN is invalid, i mistyped one number. The expected
output is 'f', PG is not supposed to raise an error and break my entire
transaction.
Is this just a bug or is this intended behaviour. And if it's not a
bug, how can i validate an ISBN number in my application - without
raising an error?
Thank you & kind regards
-- Andreas 'ads' Scherbaum
German PostgreSQL User Group
European PostgreSQL User Group - Board of Directors