Re: Validating problem in the isn contrib module
От
Andreas 'ads' Scherbaum
Тема
Re: Validating problem in the isn contrib module
Дата
Msg-id
20090307004240.0a2c705a@iridium.wars-nicht.de
Ответ на
Список
Дерево обсуждения
Validating problem in the isn contrib module Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: Validating problem in the isn contrib module "A. Kretschmer" <andreas.kretschmer@schollglas.com>
Re: Validating problem in the isn contrib module Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: Validating problem in the isn contrib module Bernd Helmle <mailings@oopsware.de>
Re: Validating problem in the isn contrib module Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: Validating problem in the isn contrib module Gregory Stark <stark@enterprisedb.com>
Re: Validating problem in the isn contrib module Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: Validating problem in the isn contrib module Bernd Helmle <mailings@oopsware.de>
Re: Validating problem in the isn contrib module Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: Validating problem in the isn contrib module Tom Lane <tgl@sss.pgh.pa.us>
Re: Validating problem in the isn contrib module Andreas 'ads' Scherbaum <adsmail@wars-nicht.de>
Re: Validating problem in the isn contrib module Gregory Stark <stark@enterprisedb.com>
On Fri, 06 Mar 2009 10:27:52 -0500 Tom Lane wrote: > Judging from the comments, is_valid (and the internal validity bit) > were a bad design decision that the author later regretted, but felt > he couldn't change for compatibility reasons. I'm not sure why not > ... we make bigger incompatible changes than that all the time. Looks a bit ugly and the way this module handles the input is unusual. > The way to validate an ISBN is exactly the same as it is for every > other data type: feed the string to the input function and see if > it throws an error. For the record here's a function which validates a text if it contains an ISBN-13, similar functions are possible for the other datatypes defined by isn: CREATE OR REPLACE FUNCTION validate_isbn13(TEXT) RETURNS BOOLEAN AS $$ DECLARE isbn_nr ALIAS FOR $1; weak_status BOOLEAN; isbn_status BOOLEAN; BEGIN -- make sure weak mode is off weak_status := isn_weak(FALSE); -- this will either return 'true' or throw an exception isbn_status := is_valid(isbn_nr::isbn13); weak_status := isn_weak(weak_status); RETURN isbn_status; EXCEPTION -- handle (only) the exception which is thrown by is_valid() WHEN invalid_text_representation THEN RETURN false; END; $$ LANGUAGE 'plpgsql'; Bye -- Andreas 'ads' Scherbaum German PostgreSQL User Group European PostgreSQL User Group - Board of Directors
В списке pgsql-hackers по дате отправления