Validating problem in the isn contrib module

From: Andreas 'ads' Scherbaum <adsmail(at)wars-nicht(dot)de>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Cc: Germán Méndez Bravo (Kronuz) <kronuz(at)hotmail(dot)com>
Subject: Validating problem in the isn contrib module
Date: 2009-03-06 01:26:12
Message-ID: 20090306022612.738c4047@iridium.wars-nicht.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sophie Yang 2009-03-06 01:32:00 Re: Use array in a dynamic statement
Previous Message Josh Berkus 2009-03-06 01:08:02 Can we drop ABSTIME?