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 1esYi5-0000Vd-L5 for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Mar 2018 18:50:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1esYi4-0001Xm-9w for pgsql-hackers@arkaria.postgresql.org; Sun, 04 Mar 2018 18:50:12 +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.89) (envelope-from ) id 1esYi3-0001XS-VI for pgsql-hackers@lists.postgresql.org; Sun, 04 Mar 2018 18:50:12 +0000 Received: from mail-wr0-x241.google.com ([2a00:1450:400c:c0c::241]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1esYhv-0001ra-RQ for pgsql-hackers@postgresql.org; Sun, 04 Mar 2018 18:50:11 +0000 Received: by mail-wr0-x241.google.com with SMTP id m12so15014471wrm.13 for ; Sun, 04 Mar 2018 10:50:02 -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=hyVBXonn5dkN1mOL3wl4zglMv7luodiotqX2zb+SbHE=; b=WIs4fdj9BzFYTpUN+vUItCpfgt19UiDVv07mXsoTakDPKOYCSOQEOf1U3oZ5DVT5S3 2dA07Pjfh27cmgrow54w9bzkr26e5yhdV+U6wq8BMLzHRSw0kVI/oO36PxDJBz9eGOec AzT/OO7diQkwOba5zSSoxyZqYeU1oHzSkkoym4mkqHGXR5ccATyYQrysJOcVU8dYYopp GmpeHh4OFKJm7Yi4vDZCpxB/OyTbXIYgyoZcRhTWGSNhfd40LsJ5KSLHgFbUWIR1VeqP hA9YdUVXcW7UUtKa31jZJ/fUxbN3yIxo3vnwhl/GDSk3QXsh6BIoY7vtp7NLR0zMnt89 ZUJw== 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=hyVBXonn5dkN1mOL3wl4zglMv7luodiotqX2zb+SbHE=; b=SdBvatMkow/v4RpVCOsGxWgzWPgZyQZDzbzB8b98wEDLuSHaJzDryBHPripltKcdQa 3Hb4jRHakZXo0j9GyQz4f9whaLlMNLfU5ZWvH9kIs/KPjV96kzZlFIgj60MzgJ7sbaej 77MawoJgzcUcBNkXUqQo1eb2n+KHJ96u6vY8csPn7igXwhUdDWglGNblaBaTtg2SlBrV 80mvD8hV2cO4hd12c4BjfuJJhDiBL1XG/Gm0Ocjk/XioYl+4r93IKGotmAPh7Ca7ASua mr+wbGCciziWtvaY3w2nq9Sq3wVNg1dU8fXpN/BZEsDZnjg22Y/lnA4bOw7lA1v7dOzf OAqw== X-Gm-Message-State: APf1xPCzF6vz+UFwQTUOj/BFHLEqRR1BuBg8dhkKQiSiZi5rUbhFmkUX pRX6qM2EZKcIc2Ccy0D4PgaqJRquU2jld2OsnAs55oT+xTj4d1RS9AVh0ZrLYs/DjN1s3YK4dgH AaAWeGWtfcwDS1tVw+LEBjaZAWcRl30ERe5TWYlO8mXIa0VymOdmHmkFmQG6GKNmUpt/+pvOg6f APktu6EIjD X-Google-Smtp-Source: AG47ELuGNLdCzyoCmRTJn/ENHY+KHKmN00L3JuQOZ5hHv32r042g7JXJo/Vgmbn6j3lGLqj4bWauOA== X-Received: by 10.223.128.75 with SMTP id 69mr11372871wrk.139.1520189397959; Sun, 04 Mar 2018 10:49:57 -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 y6sm4964864wmy.14.2018.03.04.10.49.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Mar 2018 10:49:56 -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> From: Tomas Vondra Message-ID: <07b0dcd6-45f7-a2d3-99c6-115490b2cc98@2ndquadrant.com> Date: Sun, 4 Mar 2018 19:49:53 +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: <15879.1520182782@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 05:59 PM, Tom Lane wrote: > Tomas Vondra writes: >> On 03/04/2018 02:37 AM, Tom Lane wrote: >>> I was kind of underwhelmed with these test cases, too, so I didn't >>> commit them. But they were good for proving that the bytea bug >>> wasn't hypothetical :-) > >> Underwhelmed in what sense? Should the tests be constructed in some >> other way, or do you think it's something that doesn't need the tests? > > The tests seemed pretty ugly, and I don't think they were doing much to > improve test coverage by adding all those bogus operators. Now, a look at > https://coverage.postgresql.org/src/backend/utils/adt/selfuncs.c.gcov.html > says that our test coverage for convert_to_scalar stinks, but we could > (and probably should) improve that just by testing extant operators. > Hmmm, OK. I admit the tests weren't a work of art, but I didn't consider them particularly ugly either. But that's a matter of taste, I guess. Using existing operators was the first thing I considered, of course, but to exercise this part of the code you need an operator that: 1) exercises uses ineq_histogram_selectivity (so either scalarineqsel or prefix_selectivity) 2) has oprright != oprleft 3) either oprright or oprleft is unsupported by convert_to_scalar I don't think we have such operator (built-in or in regression tests). At least I haven't found one, and this was the simplest case that I've been able to come up with. But maybe you had another idea. > A concrete argument for not creating those operators is that they pose a > risk of breaking concurrently-running tests by capturing inexact argument > matches (cf CVE-2018-1058). There are ways to get around that, eg run > the whole test inside a transaction we never commit; but I don't really > think we need the complication. > I don't think the risk of breaking other tests is very high - the operators were sufficiently "bogus" to make it unlikely, I think. But it's simple to mitigate that by either running the test in a transaction, dropping the operators at the end of the test, or just using some sufficiently unique operator name (and not '>'). 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. regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services