Validating problem in the isn contrib module - Mailing list pgsql-hackers

From Andreas 'ads' Scherbaum
Subject Validating problem in the isn contrib module
Date
Msg-id 20090306022612.738c4047@iridium.wars-nicht.de
Whole thread Raw
Responses Re: Validating problem in the isn contrib module  ("A. Kretschmer" <andreas.kretschmer@schollglas.com>)
Re: Validating problem in the isn contrib module  (Bernd Helmle <mailings@oopsware.de>)
List pgsql-hackers
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


pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Can we drop ABSTIME?
Next
From: Sophie Yang
Date:
Subject: Re: Use array in a dynamic statement