Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZHTBF-00005w-Cn for pgsql-bugs@arkaria.postgresql.org; Tue, 21 Jul 2015 08:45:41 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZHTBE-0001yS-US for pgsql-bugs@arkaria.postgresql.org; Tue, 21 Jul 2015 08:45:40 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZHTBC-0001xf-Ob for pgsql-bugs@postgresql.org; Tue, 21 Jul 2015 08:45:38 +0000 Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZHTB9-0003AJ-Gn for pgsql-bugs@postgresql.org; Tue, 21 Jul 2015 08:45:38 +0000 Received: by wibud3 with SMTP id ud3so120009376wib.0 for ; Tue, 21 Jul 2015 01:45:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:reply-to:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=nndNGPW/NX2JXFTdtUKSE7BTyO40sKxn8gp1oHdZJ1w=; b=tzLNLF1QSaUURYNA/xpS2JTeedXttlxPf+Ic1btklld+uWHW2XWLVYOaUOOzNFlxXA 3Oy1ILuFIrYht7EWooIseLhHmoY+KGU0Hn2iQplMJPjwC+dUdA2rK3dUTWp4NkSCdsr6 +vW9G3A8WoxKbgYHJMDidP6OEryIg0Hv+6syb5JJFHwwebxMLJidWCOehPohVYKNVRVa kgwttcG4F9ckiIpRJEIzICUl4GxRhIPD9E7bcG7O46zHL1EbnUj5MyzT4DAnKDPieGaX HMR8VZEwEFoNbPQd0/1owID6wMgK6qtN6waXk2DBNO3fd5X5XFOT/cu+djWEA3M6RVRW zj4Q== X-Received: by 10.180.24.198 with SMTP id w6mr28245118wif.49.1437468334377; Tue, 21 Jul 2015 01:45:34 -0700 (PDT) Received: from [192.168.1.105] (dsl-hkibrasgw1-58c38f-82.dhcp.inet.fi. [88.195.143.82]) by smtp.gmail.com with ESMTPSA id i6sm35826959wjf.29.2015.07.21.01.45.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jul 2015 01:45:33 -0700 (PDT) Message-ID: <55AE06AB.4090002@iki.fi> Date: Tue, 21 Jul 2015 11:45:31 +0300 From: Heikki Linnakangas Reply-To: hlinnaka@iki.fi User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Fabien COELHO , Tom Lane CC: bz@mailinator.com, PostgreSQL Bugs List Subject: Re: BUG #13442: ISBN doesn't always roundtrip with text References: <20150614155912.2732.93270@wrigleys.postgresql.org> <42501.1434389175@sss.pgh.pa.us> <598.1434425712@sss.pgh.pa.us> In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.4 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org 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