Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1esa54-0007ik-R5 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Mar 2018 20:18:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1esa53-0005Jb-Gs for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Mar 2018 20:18:01 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1esa53-0005JO-2H for pgsql-hackers@lists.postgresql.org; Sun, 04 Mar 2018 20:18:01 +0000 Received: from mail-wm0-x244.google.com ([2a00:1450:400c:c09::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1esa4y-0003R0-WA for pgsql-hackers@postgresql.org; Sun, 04 Mar 2018 20:17:59 +0000 Received: by mail-wm0-x244.google.com with SMTP id i3so11743866wmi.4 for ; Sun, 04 Mar 2018 12:17:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=/G+AuFOT3BSWz3VnQ9IenBablEynlpL4LubiTQXtLEs=; b=USm/JpCx3B2Q4NHkjCfJibrlZSuu9nikGjTMewYzXAJzwj1+Xx6LulvGcZBZ+nW4V/ 3irjr4PT2vovh5801xiUfJr7k5ht57L+yg54gVfLN84B3kGJkBj7ZndI5KHBYuNiqAlc Mqcdh6/cdxdcX1c/Krbm6mlIT5hyzN7UdUo0KqMNH6hE/ry6DwheyvmIqNCODVpm054P 5z+ics1RCQCyyE/vjFR97fterFHwKCw18e4cgT1WtLhquXDXdmDJnqCj6OdqrfVDwIHm BG5rYMseaq73x6ZeoMB4QsrpEM9ItNm6p/oQaE8pGVtU8Aef+qZf6DuiBErLTB2cfCRJ /Ikg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=/G+AuFOT3BSWz3VnQ9IenBablEynlpL4LubiTQXtLEs=; b=DGy8WQwaoFa6tDKE/MQBKTLewgETsRfPc5lLxQ0AvK/H5rFqf05GnIASGtBTBuTYyK jP7m2pRJhALiiPHmmSJP9S0tRIUoktbR6TZKjNc0dnuZwu0W8j2wARoo/EHBPeCdLX4k ooA7fJON/Mz1OpMzIwGTQ4s4ieFg31JUIccyuCMdGGGHml1uANx3+Pz1CqLHVDmIT7UF tuiXIK/rBBToheBmffCabhwECY/T+SCsDX+KRBYDqCnqTgaNtcZM54D5B9SOtnVD5XlO SYJYelRtmbj+3w8RbnvMBV7A+yVG6gldE0ytrSHNG1mAEbkafqpu+Sug48mugDNU6mnY CbUg== X-Gm-Message-State: AElRT7Gpztk59SOnSvdJfI5pOFlkK8lD9PuYzU8ZygSKXowJEDJVu3mq 8Qp7YXfXMbR/wnXaNDMIEqrJQ7I00PqXldVCF5++cJ9tf9zuDPPDbUEVDoOksP557oJTYGbeZDS bEqj94gHpPdWO76khi+hcLRHweSaMUMEmb1nrQo6BlJnpIlNXBKTO0fUULmU6fWrM5fG4hGnJvU i4irp0K/S1 X-Google-Smtp-Source: AG47ELv6uQI+ChfmYtFTVw84AR2WNBRLqQyPxwxsm22jQUZ1yT9zxOEfIk7o9LjwVbSE/vfEFCoAHA== X-Received: by 10.28.29.209 with SMTP id d200mr6979168wmd.149.1520194674059; Sun, 04 Mar 2018 12:17:54 -0800 (PST) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id b99sm17631431wrd.75.2018.03.04.12.17.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Mar 2018 12:17:53 -0800 (PST) Subject: Re: [HACKERS] user-defined numeric data types triggering ERROR: unsupported type To: Tom Lane Cc: PostgreSQL-development References: <9389.1506003842@sss.pgh.pa.us> <4b444362-4240-49e0-3523-724e5932b060@2ndquadrant.com> <24767.1506180446@sss.pgh.pa.us> <14597.1520038563@sss.pgh.pa.us> <42f4e37e-f923-6ea9-4172-cdec5a8c2d25@2ndquadrant.com> <11916.1520127473@sss.pgh.pa.us> <82f29126-df5a-d4bc-f5b5-47233e29aaa6@2ndquadrant.com> <15879.1520182782@sss.pgh.pa.us> <07b0dcd6-45f7-a2d3-99c6-115490b2cc98@2ndquadrant.com> <25629.1520192235@sss.pgh.pa.us> From: Tomas Vondra Message-ID: Date: Sun, 4 Mar 2018 21:17:50 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <25629.1520192235@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 03/04/2018 08:37 PM, Tom Lane wrote: > Tomas Vondra writes: >> FWIW I originally constructed the tests merely to verify that the fix >> actually fixes the issue, but I think we should add some tests to make >> sure it does not get broken in the future. It took quite a bit of time >> until someone even hit the issue, so a breakage may easily get unnoticed >> for a long time. > > Oh, well, that was another problem I had with it: those tests do basically > nothing to ensure that we won't add another such problem in the future. > If somebody added support for a new type FOO, and forgot to ensure that > FOO-vs-not-FOO cases behaved sanely, these tests wouldn't catch it. > (At least, not unless the somebody added a FOO-vs-not-FOO case to these > tests, but it's hardly likely they'd do that if they hadn't considered > the possibility.) > I don't follow. How would adding new custom types break the checks? If someone adds a new type along with operators for comparing it with the built-in types (supported by convert_to_scalar), then surely it would hit a code path tested by those tests. > I think actually having put in the coding patterns for what to do with > unsupported cases is our best defense against similar oversights in > future: probably people will copy those coding patterns. Maybe the bytea > precedent proves that some people will fail to think about it no matter > what, but I don't know what more we can do. > Maybe. It's true the tests served more like a safety against someone messing with convert_to_scalar (e.g. by adding support for new types), and undoing the fix for the current data types in some way without realizing it. It wouldn't catch issues in handling of additional data types, of course (like the bytea case). So perhaps the best thing we can do is documenting this in the comment before convert_to_scalar? kind regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services